3232 - name : " Checkout"
3333 uses : actions/checkout@v4
3434 with :
35- fetch-depth : 3
35+ ref : ${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_branch || github.ref }}
36+ fetch-depth : 1
3637
3738 - name : " Check for changes in src folder"
3839 id : checkChanges
5051 echo "${newLine}"
5152 echo "${yellow}Checking if there has been changes to source code by running git diff on the src folder excluding markdown files${reset}"
5253
53- changes=$(git diff ${{ github.ref }}^ ${{ github.ref }} --ignore-all-space --name-only -- src/)
54+ GIT_REF=${{ github.ref }}
55+
56+ if [ "$GITHUB_EVENT_NAME" == "workflow_run" ]; then
57+ GIT_REF=${{ github.event.workflow_run.head_branch }}
58+ fi
59+
60+ changes=$(git diff "$GIT_REF"^ "$GIT_REF" --ignore-all-space --name-only -- src/)
5461 nonMarkdownChanges=""
5562 continueWorkflow=true
5663
9299 uses : actions/checkout@v4
93100 with :
94101 fetch-depth : 0
102+ ref : ${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_branch || github.ref }}
95103
96104 - name : " Set Git Config"
97105 run : |
@@ -101,7 +109,7 @@ jobs:
101109
102110 - name : Authenticate node
103111 uses : navikt/sf-platform/.github/actions/authenticateNode@main
104- if : ${{ github.ref_name == 'refs/heads/ main' }}
112+ if : ${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_branch == 'main' || github. ref_name == 'main' }}
105113
106114 - name : Authenticate DevHub
107115 uses : navikt/sf-platform/.github/actions/authenticateOrg@main
@@ -124,18 +132,18 @@ jobs:
124132
125133 - name : Publish artifacts
126134 uses : navikt/sf-platform/.github/actions/publishArtifact@main
127- if : ${{ github.ref_name == 'refs/heads/ main' }}
135+ if : ${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_branch == 'main' || github. ref_name == 'main' }}
128136 with :
129137 nodeToken : ${{ secrets.GITHUB_TOKEN }}
130138
131139 - name : Generate Release Name
132- if : ${{ github.ref_name == 'refs/heads/ main' }}
140+ if : ${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_branch == 'main' || github. ref_name == 'main' }}
133141 id : generate_name
134142 run : |
135143 echo "releaseName=sf-platform_$(date +%s%3N)" >> $GITHUB_OUTPUT
136144
137145 - name : Generate Release Definition
138- if : ${{ github.ref_name == 'refs/heads/ main' }}
146+ if : ${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_branch == 'main' || github. ref_name == 'main' }}
139147 uses : navikt/sf-platform/.github/actions/generateReleaseDefinition@main
140148 with :
141149 branchToCommitTo : ${{ github.ref }}
0 commit comments