Skip to content

Commit 149b3a0

Browse files
Artyopaanm
authored andcommitted
ci: fix PR branch pull step on stable pushes
On workflow_dispatch event, pr-number also carry the name of the branch instead of the PR number when the branch isn't associated with any PR. Such example can be found on stable branch workflow-dispatch : https://github.com/cilium/cilium/actions/runs/23629031538/job/68824091132 In order to avoid error on the PR research with git CLI, we check when the context-ref equals the pr-number. Knowing it's a case where the branch isn't associated with any PR, we then use the context-ref as a base branch to carry on the workflow. Signed-off-by: Antony Reynaud <antony.reynaud@isovalent.com>
1 parent 95ce3ca commit 149b3a0

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

.github/workflows/conformance-aws-cni.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,11 @@ jobs:
228228
env:
229229
GH_TOKEN: ${{ github.token }}
230230
run: |
231-
BASE_BRANCH=$(gh pr view ${{ inputs.PR-number }} --json baseRefName -q .baseRefName)
231+
if [[ "${{ inputs.PR-number }}" == "${{ inputs.context-ref }}" ]]; then
232+
BASE_BRANCH="${{ inputs.context-ref }}"
233+
else
234+
BASE_BRANCH=$(gh pr view ${{ inputs.PR-number }} --json baseRefName -q .baseRefName)
235+
fi
232236
echo "base-branch=$BASE_BRANCH" >> $GITHUB_OUTPUT
233237
echo "Base branch for PR #${{ inputs.PR-number }}: $BASE_BRANCH"
234238

.github/workflows/conformance-eks.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,11 @@ jobs:
302302
env:
303303
GH_TOKEN: ${{ github.token }}
304304
run: |
305-
BASE_BRANCH=$(gh pr view ${{ inputs.PR-number }} --json baseRefName -q .baseRefName)
305+
if [[ "${{ inputs.PR-number }}" == "${{ inputs.context-ref }}" ]]; then
306+
BASE_BRANCH="${{ inputs.context-ref }}"
307+
else
308+
BASE_BRANCH=$(gh pr view ${{ inputs.PR-number }} --json baseRefName -q .baseRefName)
309+
fi
306310
echo "base-branch=$BASE_BRANCH" >> $GITHUB_OUTPUT
307311
echo "Base branch for PR #${{ inputs.PR-number }}: $BASE_BRANCH"
308312

0 commit comments

Comments
 (0)