Skip to content

Commit 98f054b

Browse files
committed
Merge branch 'main' into customDaoFix
2 parents 917d098 + 27edfe2 commit 98f054b

File tree

1 file changed

+60
-2
lines changed

1 file changed

+60
-2
lines changed

.github/workflows/buildAndPublish.yml

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ concurrency:
1010
group: ${{ github.workflow }}-${{ github.ref }}
1111
cancel-in-progress: true
1212
jobs:
13-
buildAndPublish:
14-
name: Build and Publish
13+
checkChanges:
14+
name: Check changes
1515
# Always run on workflow call and workflow dispatch
1616
# Only run on workflow_run if there has been a change in the src folder,
1717
# excluding markdown files
@@ -23,7 +23,65 @@ jobs:
2323
github.event.workflow_run.conclusion == 'success'
2424
)
2525
}}
26+
runs-on: ubuntu-latest
27+
outputs:
28+
continueWorkflow: ${{ steps.checkChanges.outputs.continueWorkflow }}
29+
permissions:
30+
contents: read
31+
steps:
32+
- name: "Checkout"
33+
uses: actions/checkout@v4
34+
with:
35+
fetch-depth: 2
36+
37+
- name: "Check for changes in src folder"
38+
id: checkChanges
39+
run: |
40+
printf -v red '\033[0;31m'
41+
printf -v yellow '\033[0;33m'
42+
printf -v green '\033[0;32m'
43+
printf -v bold '\033[1m'
44+
printf -v reset '\033[0m'
45+
printf -v newLine '\n'
2646
47+
echo "${yellow}${bold}------------------------------------------------------------------------------------------${reset}"
48+
echo "${yellow}${bold}Check for changes in source code${reset}"
49+
echo "${yellow}${bold}------------------------------------------------------------------------------------------${reset}"
50+
51+
echo "${yellow}Checking if there has been changes to source code by running git diff on the src folder excluding markdown files${reset}"
52+
53+
changes=$(git diff HEAD^ HEAD --ignore-all-space --name-only -- src/)
54+
nonMarkdownChanges=""
55+
continueWorkflow=true
56+
57+
if [ -n "$changes" ]; then
58+
echo "${yellow}${bold}Changes:${reset}"
59+
echo "$changes"
60+
nonMarkdownChanges=$(echo $changes | grep -v '\.md$')
61+
62+
if [ -n "$nonMarkdownChanges" ]; then
63+
echo "${newLine}"
64+
echo "${green}${bold}There have been changes to non-Markdown files! Start building 🏗️${reset}"
65+
else
66+
echo "${newLine}"
67+
echo "${yellow}No changes to non-Markdown files detected. Cancelling the workflow${reset}"
68+
continueWorkflow=false
69+
fi
70+
else
71+
echo "${newLine}"
72+
echo "${yellow}No changes to files in src folder. Cancelling the workflow${reset}"
73+
continueWorkflow=false
74+
fi
75+
76+
echo "continueWorkflow=$continueWorkflow" >> "$GITHUB_OUTPUT"
77+
78+
echo "${newLine}"
79+
echo "${yellow}${bold}------------------------------------------------------------------------------------------${reset}"
80+
81+
buildAndPublish:
82+
name: Build and Publish
83+
needs: checkChanges
84+
if: ${{ needs.checkChanges.outputs.continueWorkflow == 'true' }}
2785
runs-on: ubuntu-latest
2886
container: ghcr.io/flxbl-io/sfp:${{ vars.SFP_CONTAINER_VERSION }}
2987
permissions:

0 commit comments

Comments
 (0)