4646
4747jobs :
4848
49- get-pr-number :
50- runs-on : ubuntu-latest
51- permissions :
52- pull-requests : read
53- contents : read
54- outputs :
55- PR_NUM_TAG : ${{ steps.get_pr_num.PR_NUM_TAG }}
56- steps :
57- - uses : actions/checkout@v4
58- with :
59- fetch-depth : 2
60- token : ${{ secrets.GITHUB_TOKEN }}
61-
62- - name : Fetch PR Number
63- id : get_pr_num
64- env :
65- GH_TOKEN : ${{ github.token }}
66- run : |
67- # Find the PR associated with the current commit SHA
68- PR_NUM=$(gh api repos/${{ github.repository }}/commits/${{ github.sha }}/pulls --jq '.[0].number')
69-
70- if [ -z "$PR_NUM" ]; then
71- echo "No PR found for this tag push."
72- echo "PR_NUM=null" >> $GITHUB_OUTPUT
73- else
74- echo "Found PR: $PR_NUM"
75- PR_NUM_TAG="pr${PR_NUM}"
76- echo "PR tag: $PR_NUM_TAG"
77-
78- echo "PR_NUM_TAG=$PR_NUM_TAG" >> $GITHUB_OUTPUT
79- fi
80-
8149 get-functions :
8250 runs-on : ubuntu-latest
8351 permissions :
@@ -117,10 +85,11 @@ jobs:
11785 pull-requests : read
11886 id-token : write
11987 packages : write
120- needs : [get-functions, get-pr-number ]
88+ needs : [get-functions]
12189 outputs :
12290 DOTNET_BASE_IMAGE : ${{ steps.set-image-tags.outputs.DOTNET_BASE_IMAGE }}
12391 FUNCTION_BASE_IMAGE : ${{ steps.set-image-tags.outputs.FUNCTION_BASE_IMAGE }}
92+
12493 steps :
12594 - uses : actions/checkout@v4
12695 with :
@@ -146,10 +115,11 @@ jobs:
146115 working-directory : ./
147116 if : ${{ steps.detect-base-image-changes.outputs.BASE_IMAGE_CHANGE == 'true' || github.ref == 'refs/heads/main' }}
148117 continue-on-error : false
149- env :
150- PR_NUM_TAG : ${{ needs.get-pr-number.outputs.PR_NUM_TAG }}
151118 run : |
152119 SHORT_COMMIT_HASH=$(git rev-parse --short ${GITHUB_SHA})
120+ PR_NUM=$(gh api repos/${{ github.repository }}/commits/${{ github.sha }}/pulls --jq '.[0].number')
121+ PR_NUM_TAG="pr${PR_NUM}"
122+
153123 echo $SHORT_COMMIT_HASH
154124 echo $PR_NUM_TAG
155125 echo $GITHUB_REF
@@ -173,10 +143,10 @@ jobs:
173143
174144 - name : Set Image Tags
175145 id : set-image-tags
176- env :
177- PR_NUM_TAG : ${{ needs.get-pr-number.outputs.PR_NUM_TAG }}
178146 run : |
179147
148+ PR_NUM=$(gh api repos/${{ github.repository }}/commits/${{ github.sha }}/pulls --jq '.[0].number')
149+ PR_NUM_TAG="pr${PR_NUM}"
180150 IMAGE_TAG="latest"
181151
182152 # if [[ ${{steps.detect-base-image-changes.outputs.BASE_IMAGE_CHANGE}} == 'true' ]]; then
@@ -201,7 +171,7 @@ jobs:
201171 id-token : write
202172 contents : read
203173 pull-requests : read
204- needs : [get-functions, build-base-images, get-pr-number ]
174+ needs : [get-functions, build-base-images]
205175 strategy :
206176 matrix :
207177 function : ${{ fromJSON(needs.get-functions.outputs.FUNC_NAMES) }}
@@ -240,7 +210,6 @@ jobs:
240210 env :
241211 GH_TOKEN : ${{ github.token }}
242212 ENVIRONMENT_TAG : ${{ inputs.environment_tag }}
243- PR_NUM_TAG : ${{ needs.get-pr-number.outputs.PR_NUM_TAG }}
244213 continue-on-error : false
245214 run : |
246215 echo "The branch is: ${GITHUB_REF}"
@@ -253,6 +222,8 @@ jobs:
253222 # echo "ORIGINATING_BRANCH: ${ORIGINATING_BRANCH}"
254223 # PR_NUM_TAG=$(echo ${PULLS_JSON} | jq -r '.[].number')
255224 # fi
225+ PR_NUM=$(gh api repos/${{ github.repository }}/commits/${{ github.sha }}/pulls --jq '.[0].number')
226+ PR_NUM_TAG="pr${PR_NUM}"
256227
257228 DEVTEST_PR_NUM_TAG="devtest_${PR_NUM_TAG}"
258229 echo "Devtest Pr Num tag: ${DEVTEST_PR_NUM_TAG}"
@@ -275,7 +246,6 @@ jobs:
275246 COMPOSE_FILE : ${{ inputs.docker_compose_file }}
276247 PROJECT_NAME : ${{ inputs.project_name }}
277248 ACR_NAME : ${{ secrets.acr_name }}
278- PR_NUM_TAG : ${{ needs.get-pr-number.outputs.PR_NUM_TAG }}
279249 run : |
280250 function=${{ matrix.function }}
281251
0 commit comments