@@ -46,29 +46,39 @@ 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- changes=$(git diff HEAD^ HEAD --ignore-all-space --name-only -- src/ | grep -v '\.md$' )
49+ changes=$(git diff HEAD^ HEAD --ignore-all-space --name-only -- src/)
5050
5151 if [ -n "$changes" ]; then
52- echo "There have been changes to non-Markdown files!"
52+ echo "There have been changes!"
53+ changes=$(echo $changes | grep -v '\.md$')
54+
55+ if [ -n "$changes" ]; then
56+ echo "There have been changes to non-Markdown files!"
57+ else
58+ echo "Only change to markdown!"
59+
60+ echo "No changes to non-Markdown files detected. Cancelling the workflow"
61+
62+ # Use GitHub context variables directly
63+ REPO="${{ github.repository }}"
64+ RUN_ID="${{ github.run_id }}"
65+
66+ # API call to cancel the workflow
67+ curl -X POST \
68+ -H "Accept: application/vnd.github.v3+json" \
69+ -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
70+ "https://api.github.com/repos/$REPO/actions/runs/$RUN_ID/cancel"
71+
72+ # Wait for cancellation to be processed
73+ sleep 5
74+
75+ echo "Cancellation request sent. Note that cancellation might not be immediate."
76+ exit 0 # Explicitly exit with success to avoid running further steps if not needed
77+ fi
5378 else
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
79+ echo "No Changes"
7180 fi
81+
7282 echo "::endgroup::"
7383
7484 - name : Authenticate node
0 commit comments