@@ -117,8 +117,14 @@ jobs:
117117 run : |
118118
119119 echo "The branch is: ${GITHUB_REF}"
120- PR_NUM=$(gh api repos/${{ github.repository }}/commits/${{ github.sha }}/pulls --jq '.[0].number')
121- PR_NUM_TAG="pr${PR_NUM}"
120+ PR_NUM=$(gh api repos/${{ github.repository }}/commits/${{ github.sha }}/pulls --jq '.[0].number' 2>/dev/null || true)
121+ if [ -n "${PR_NUM}" ] && [ "${PR_NUM}" != "null" ]; then
122+ PR_NUM_TAG="pr${PR_NUM}"
123+ echo "Tag source: PR (${PR_NUM})"
124+ else
125+ PR_NUM_TAG="${GITHUB_REF_NAME//\//-}"
126+ echo "Tag source: fallback ref (${GITHUB_REF_NAME})"
127+ fi
122128 SHORT_COMMIT_HASH=$(git rev-parse --short ${GITHUB_SHA})
123129
124130
@@ -149,8 +155,14 @@ jobs:
149155 GH_TOKEN : ${{ github.token }}
150156 run : |
151157
152- PR_NUM=$(gh api repos/${{ github.repository }}/commits/${{ github.sha }}/pulls --jq '.[0].number')
153- PR_NUM_TAG="pr${PR_NUM}"
158+ PR_NUM=$(gh api repos/${{ github.repository }}/commits/${{ github.sha }}/pulls --jq '.[0].number' 2>/dev/null || true)
159+ if [ -n "${PR_NUM}" ] && [ "${PR_NUM}" != "null" ]; then
160+ PR_NUM_TAG="pr${PR_NUM}"
161+ echo "Tag source: PR (${PR_NUM})"
162+ else
163+ PR_NUM_TAG="${GITHUB_REF_NAME//\//-}"
164+ echo "Tag source: fallback ref (${GITHUB_REF_NAME})"
165+ fi
154166 IMAGE_TAG="latest"
155167
156168 if [[ ${{steps.detect-base-image-changes.outputs.BASE_IMAGE_CHANGE}} == 'true' ]]; then
@@ -213,8 +225,14 @@ jobs:
213225 ENVIRONMENT_TAG : ${{ inputs.environment_tag }}
214226 continue-on-error : false
215227 run : |
216- PR_NUM=$(gh api repos/${{ github.repository }}/commits/${{ github.sha }}/pulls --jq '.[0].number')
217- PR_NUM_TAG="pr${PR_NUM}"
228+ PR_NUM=$(gh api repos/${{ github.repository }}/commits/${{ github.sha }}/pulls --jq '.[0].number' 2>/dev/null || true)
229+ if [ -n "${PR_NUM}" ] && [ "${PR_NUM}" != "null" ]; then
230+ PR_NUM_TAG="pr${PR_NUM}"
231+ echo "Tag source: PR (${PR_NUM})"
232+ else
233+ PR_NUM_TAG="${GITHUB_REF_NAME//\//-}"
234+ echo "Tag source: fallback ref (${GITHUB_REF_NAME})"
235+ fi
218236 DEVTEST_PR_NUM_TAG="devtest_${PR_NUM_TAG}"
219237
220238 echo "The branch is: ${GITHUB_REF}"
0 commit comments