@@ -46,32 +46,28 @@ jobs:
4646 echo "::group::Check for changes in source code"
4747 echo "Checking if there has been changes to source code by running git diff on the src folder excluding markdown files"
4848
49- if changes=$(git diff HEAD^ HEAD --ignore-all-space --name-only -- src/ | grep -v '\.md$' 2>&1); then
50- if [ -n "$changes" ]; then
51- echo "There have been changes to non-Markdown files!"
52- else
53- echo "No changes to non-Markdown files detected. Cancelling the workflow"
54-
55- # Use GitHub context variables directly
56- REPO="${{ github.repository }}"
57- RUN_ID="${{ github.run_id }}"
58-
59- # API call to cancel the workflow
60- curl -X POST \
61- -H "Accept: application/vnd.github.v3+json" \
62- -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
63- "https://api.github.com/repos/$REPO/actions/runs/$RUN_ID/cancel"
64-
65- # Wait for cancellation to be processed
66- sleep 5
67-
68- echo "Cancellation request sent. Note that cancellation might not be immediate."
69- exit 0 # Explicitly exit with success to avoid running further steps if not needed
70- fi
49+ changes=$(git diff HEAD^ HEAD --ignore-all-space --name-only -- src/ | grep -v '\.md$'
50+
51+ if [ -n "$changes" ]; then
52+ echo "There have been changes to non-Markdown files!"
7153 else
72- # If git diff fails for any reason, this block will handle the error
73- echo "::error title=Error executing git diff::$changes"
74- exit 1
54+ echo "No changes to non-Markdown files detected. Cancelling the workflow"
55+
56+ # Use GitHub context variables directly
57+ REPO="${{ github.repository }}"
58+ RUN_ID="${{ github.run_id }}"
59+
60+ # API call to cancel the workflow
61+ curl -X POST \
62+ -H "Accept: application/vnd.github.v3+json" \
63+ -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
64+ "https://api.github.com/repos/$REPO/actions/runs/$RUN_ID/cancel"
65+
66+ # Wait for cancellation to be processed
67+ sleep 5
68+
69+ echo "Cancellation request sent. Note that cancellation might not be immediate."
70+ exit 0 # Explicitly exit with success to avoid running further steps if not needed
7571 fi
7672 echo "::endgroup::"
7773
0 commit comments