Skip to content

Commit ea0ce3f

Browse files
committed
feat: devtest using pr number as image identifier
1 parent 8e49750 commit ea0ce3f

1 file changed

Lines changed: 31 additions & 1 deletion

File tree

.github/workflows/stage-3-build-images-devtest.yaml

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,36 @@ on:
4545
required: true
4646

4747
jobs:
48+
49+
get-pr-number:
50+
runs-on: ubuntu-latest
51+
permissions:
52+
pull-requests: read
53+
contents: read
54+
outputs:
55+
GET_PR_NUM: ${{ steps.get_pr_num.outputs.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_TAG=$(gh pr list --sha ${{ github.sha }} --state all --json number --jq '.[0].number')
69+
70+
if [ -z "$PR_NUM_TAG" ]; then
71+
echo "No PR found for this tag push."
72+
echo "PR_NUM_TAG=null" >> $GITHUB_OUTPUT
73+
else
74+
echo "Found PR: $PR_NUM_TAG"
75+
echo "PR_NUM_TAG=$PR_NUM_TAG" >> $GITHUB_OUTPUT
76+
fi
77+
4878
get-functions:
4979
runs-on: ubuntu-latest
5080
permissions:
@@ -113,7 +143,7 @@ jobs:
113143
if: ${{ steps.detect-base-image-changes.outputs.BASE_IMAGE_CHANGE == 'true' || github.ref == 'refs/heads/main' }}
114144
continue-on-error: false
115145
run: |
116-
PR_NUM_TAG=$(echo "${GITHUB_REF}" | sed 's/refs\/pull\/\([0-9]*\)\/merge/\1/')
146+
PR_NUM_TAG=${PR_NUM_TAG}
117147
SHORT_COMMIT_HASH=$(git rev-parse --short ${GITHUB_SHA})
118148
echo $SHORT_COMMIT_HASH
119149
echo $PR_NUM_TAG

0 commit comments

Comments
 (0)