1212 name : Check changes
1313 runs-on : ubuntu-latest
1414 outputs :
15- continueWorkflow : ${{ steps.checkChanges.outputs.continueWorkflow }}
15+ hasSrcChanges : ${{ steps.checkChanges.outputs.hasSrcChanges }}
1616 permissions :
1717 contents : read
1818 steps :
@@ -22,67 +22,13 @@ jobs:
2222 fetch-depth : 0
2323 persist-credentials : false
2424
25- - name : " Check changes since last commit in src folder "
25+ - uses : navikt/sf-platform/.github/actions/checkForPackageChanges@8a76cf6726f88608113bd6cc313b4a6728ce476a
2626 id : checkChanges
27- run : |
28- printf -v red '\033[0;31m'
29- printf -v yellow '\033[0;33m'
30- printf -v green '\033[0;32m'
31- printf -v bold '\033[1m'
32- printf -v reset '\033[0m'
33- printf -v newLine '\n'
34-
35- continueWorkflow=true
36- changes=""
37- nonMarkdownChanges=""
38-
39- echo "${yellow}${bold}------------------------------------------------------------------------------------------${reset}"
40- echo "${yellow}${bold}Check changes since last commit in src folder${reset}"
41- echo "${yellow}${bold}------------------------------------------------------------------------------------------${reset}"
42-
43- if [ "${EVENT_NAME}" = "pull_request" ]; then
44- changes=$(git diff "${PR_BASE_SHA}".."${PR_HEAD_SHA}" --ignore-all-space --name-only -- src/)
45- else
46- # Fetch the parent commit SHA dynamically, ensuring we're always looking at the immediate predecessor.
47- changes=$(git diff $(git rev-parse "${REF_NAME}^") "${REF_NAME}" --ignore-all-space --name-only -- src/)
48- fi
49-
50- if [ "${EVENT_NAME}" = "workflow_dispatch" ]; then
51- echo "${yellow}${bold}------------------------------------------------------------------------------------------${reset}"
52- echo "${yellow}${bold}Manual run. Start building 🏗️${reset}"
53- echo "${yellow}${bold}------------------------------------------------------------------------------------------${reset}"
54- else
55- echo "${yellow}Checking if there has been changes to source code by running git diff on the src folder excluding markdown files${reset}"
56-
57- if [ -n "$changes" ]; then
58- nonMarkdownChanges=$(echo $changes | grep -v '\.md$')
59-
60- if [ -n "$nonMarkdownChanges" ]; then
61- echo "${green}${bold}There have been changes to non-Markdown files! Start building 🏗️${reset}"
62- else
63- echo "${yellow}No changes to non-Markdown files detected.${reset}"
64- echo "${yellow}Cancelling the workflow${reset}"
65- continueWorkflow=false
66- fi
67- else
68- echo "${yellow}No changes to files in src folder. Cancelling the workflow${reset}"
69- continueWorkflow=false
70- fi
71-
72- echo "${yellow}${bold}------------------------------------------------------------------------------------------${reset}"
73- fi
74-
75- echo "continueWorkflow=$continueWorkflow" >> "$GITHUB_OUTPUT"
76- env :
77- PR_BASE_SHA : ${{ github.event.pull_request.base.sha }}
78- PR_HEAD_SHA : ${{ github.event.pull_request.head.sha }}
79- REF_NAME : ${{ github.ref_name }}
80- EVENT_NAME : ${{ github.event_name }}
8127
8228 buildAndPublish :
8329 name : Build and Publish
8430 needs : checkChanges
85- if : ${{ needs.checkChanges.outputs.continueWorkflow == 'true' }}
31+ if : ${{ needs.checkChanges.outputs.hasSrcChanges == 'true' && github.ref_name == 'main ' }}
8632 runs-on : ubuntu-latest
8733 container : ghcr.io/flxbl-io/sfp:${{ vars.SFP_CONTAINER_VERSION }}
8834 permissions :
9642 persist-credentials : true
9743
9844 - name : Authenticate node
99- if : ${{ github.ref_name == 'main' }}
10045 uses : actions/setup-node@v4
10146 with :
10247 registry-url : " https://npm.pkg.github.com"
@@ -108,41 +53,33 @@ jobs:
10853 alias : " devhub"
10954 setDefaultDevhubUsername : " true"
11055
111- - name : Validate against CI Pool
112- uses : navikt/sf-platform/.github/actions/ciValidate@79ad1077a810db336f3e39606a25a4a505d5012c
113- with :
114- devhub : " devhub"
115- pools : ${{ vars.DEFAULT_CI_POOL }}
116- ref : ${{ github.event_name == 'pull_request' && github.sha || '' }}
117- baseRef : ${{ github.event_name == 'pull_request' && github.sha || '' }}
118-
119- - name : Delete Stale Validation Org
120- if : ${{ failure() }}
121- run : sf org delete scratch -p
122-
123- - name : Quick build
124- if : ${{ github.ref_name != 'main' }}
125- uses : navikt/sf-platform/.github/actions/ciQuickBuild@f318a266c5a7add9c091f9d3480164fed8abfc08
126-
12756 - name : Build
128- if : ${{ github.ref_name == 'main' }}
12957 run : |
130- sfp build --devhubalias devhub --diffcheck --buildnumber ${GITHUB_RUN_ID} --branch ${GITHUB_REF#refs/heads/}
58+ sfp build --devhubalias devhub --diffcheck --buildnumber ${GITHUB_RUN_ID} --branch main --releaseconfig config/releaseConfig.yml
59+ if [ -d "artifacts" ] && [ -n "$(ls -A artifacts)" ]; then
60+ echo "Artifacts found"
61+ else
62+ echo "No artifacts found"
63+ fi
13164
13265 - name : Publish artifacts
133- if : ${{ github.ref_name == 'main' }}
134- uses : navikt/sf-platform/.github/actions/publishArtifact@f318a266c5a7add9c091f9d3480164fed8abfc08
135- with :
136- nodeToken : ${{ secrets.GITHUB_TOKEN }}
66+ run : |
67+ if [ -d "artifacts" ] && [ -n "$(ls -A artifacts)" ]; then
68+ sfp publish --artifactdir artifacts --npm --scope @${SCOPE} --devhubalias devhub --loglevel ${SFP_LOG_LEVEL} --gittag --pushgittag --logsgroupsymbol ::group::,::endgroup::
69+ else
70+ echo "No artifacts to publish"
71+ fi
72+ env :
73+ NODE_AUTH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
74+ SFP_LOG_LEVEL : ${{ vars.SFP_LOG_LEVEL }}
75+ SCOPE : ${{ github.repository_owner }}
13776
13877 - name : Generate Release Name
139- if : ${{ github.ref_name == 'main' }}
14078 id : generate_name
14179 run : |
14280 echo "releaseName=sf-platform_$(date +%s%3N)" >> $GITHUB_OUTPUT
14381
14482 - name : Generate Release Definition
145- if : ${{ github.ref_name == 'main' }}
14683 run : |
14784 sfp releasedefinition generate --gitref ${GIT_REF} --configfile ${PATH_TO_CONFIG_FILE} --releasename ${RELEASE_NAME} --directory ${DIRECTORY} --branchname ${BRANCH_NAME}
14885 env :
15390 BRANCH_NAME : ${{ github.ref_name }}
15491
15592 - name : Commit release definition
156- if : ${{ github.ref_name == 'main' }}
15793 uses : navikt/sf-platform/.github/actions/commitFiles@f318a266c5a7add9c091f9d3480164fed8abfc08
15894 with :
15995 files : " release-definition/${{ steps.generate_name.outputs.releaseName }}.yml"
0 commit comments