44 secrets :
55 SF_DEVHUB_URL :
66 required : true
7+ workflow_dispatch :
78concurrency :
89 group : ${{ github.workflow }}-${{ github.ref_name }}
910jobs :
2021 with :
2122 fetch-depth : 0
2223
23- - name : " Check for changes in src folder"
24+ - name : " Check changes since last commit in src folder"
2425 id : checkChanges
2526 run : |
2627 printf -v red '\033[0;31m'
@@ -30,43 +31,56 @@ jobs:
3031 printf -v reset '\033[0m'
3132 printf -v newLine '\n'
3233
34+ continueWorkflow=true
35+ changes=""
36+ nonMarkdownChanges=""
37+
3338 echo "${yellow}${bold}------------------------------------------------------------------------------------------${reset}"
34- echo "${yellow}${bold}Check for changes in source code$ {reset}"
39+ echo "${yellow}${bold}Check changes since last commit in src folder {reset}"
3540 echo "${yellow}${bold}------------------------------------------------------------------------------------------${reset}"
3641
37- echo "${yellow}Checking if there has been changes to source code by running git diff on the src folder excluding markdown files${reset}"
38-
3942 if [ ${{ github.event_name == 'pull_request' }} ]; then
4043 changes=$(git diff "${{ github.event.pull_request.base.sha }}".."${{ github.event.pull_request.head.sha }}" --ignore-all-space --name-only -- src/)
4144 else
4245 # Fetch the parent commit SHA dynamically, ensuring we're always looking at the immediate predecessor.
4346 changes=$(git diff $(git rev-parse "${{ github.ref_name }}^") "${{ github.ref_name }}" --ignore-all-space --name-only -- src/)
4447 fi
4548
46- nonMarkdownChanges=""
47- continueWorkflow=true
48-
49- echo "${yellow}${bold}Changes:${reset}"
49+ echo "${yellow}${bold}Changes since last commit:${reset}"
5050 echo "$changes"
51+ echo "${yellow}${bold}------------------------------------------------------------------------------------------${reset}"
52+ echo "${newLine}"
5153
52- if [ -n "$changes" ]; then
53- nonMarkdownChanges=$(echo $changes | grep -v '\.md$')
54-
55- if [ -n "$nonMarkdownChanges" ]; then
56- echo "${green}${bold}There have been changes to non-Markdown files! Start building 🏗️${reset}"
54+ if [ ${{ github.event_name == 'workflow_dispatch' }} ]; then
55+ echo "${yellow}${bold}------------------------------------------------------------------------------------------${reset}"
56+ echo "${yellow}${bold}Manual run. Start building 🏗️{reset}"
57+ echo "${yellow}${bold}------------------------------------------------------------------------------------------${reset}"
58+ else
59+ echo "${yellow}${bold}------------------------------------------------------------------------------------------${reset}"
60+ echo "${yellow}${bold}Check for changes in source code${reset}"
61+ echo "${yellow}${bold}------------------------------------------------------------------------------------------${reset}"
62+
63+ echo "${yellow}Checking if there has been changes to source code by running git diff on the src folder excluding markdown files${reset}"
64+
65+ if [ -n "$changes" ]; then
66+ nonMarkdownChanges=$(echo $changes | grep -v '\.md$')
67+
68+ if [ -n "$nonMarkdownChanges" ]; then
69+ echo "${green}${bold}There have been changes to non-Markdown files! Start building 🏗️${reset}"
70+ else
71+ echo "${yellow}No changes to non-Markdown files detected. Cancelling the workflow${reset}"
72+ continueWorkflow=false
73+ fi
74+
5775 else
58- echo "${yellow}No changes to non-Markdown files detected . Cancelling the workflow${reset}"
76+ echo "${yellow}No changes to files in src folder . Cancelling the workflow${reset}"
5977 continueWorkflow=false
6078 fi
61-
62- else
63- echo "${yellow}No changes to files in src folder. Cancelling the workflow${reset}"
64- continueWorkflow=false
65- fi
6679
67- echo "continueWorkflow=$continueWorkflow" >> "$GITHUB_OUTPUT"
80+ echo "continueWorkflow=$continueWorkflow" >> "$GITHUB_OUTPUT"
6881
69- echo "${yellow}${bold}------------------------------------------------------------------------------------------${reset}"
82+ echo "${yellow}${bold}------------------------------------------------------------------------------------------${reset}"
83+ fi
7084
7185 buildAndPublish :
7286 name : Build and Publish
@@ -108,9 +122,11 @@ jobs:
108122 baseRef : ${{ github.event_name == 'pull_request' && github.sha || '' }}
109123
110124 - name : Quick build
125+ if : ${{ github.ref_name != 'main' }}
111126 uses : navikt/sf-platform/.github/actions/ciQuickBuild@314943ae84fcb0285bde0791a1aa71a1b4ee91c3
112127
113128 - name : Build
129+ if : ${{ github.ref_name == 'main' }}
114130 uses : navikt/sf-platform/.github/actions/build@59bae8628c223a6ee3c88dc4cb1d31b3ee421d52
115131
116132 - name : Publish artifacts
0 commit comments