Skip to content

Commit 85e1ee2

Browse files
authored
cicd/bug: query live labels in hold gate instead of (stale) event payload (#2200)
* fix(ci): query live labels in hold gate instead of stale event payload github.event.pull_request.labels is frozen at trigger time, so a manual rerun of a failed hold-gate job kept failing after the hold label was removed. Fetch current labels via the GitHub API instead. Fixes #2199 Signed-off-by: Etai Lev Ran <elevran@gmail.com> * fix(ci): move hold-gate rerun comment inline and shorten it Signed-off-by: Etai Lev Ran <elevran@gmail.com> * fix(ci): make hold-gate blocking labels an extensible array Signed-off-by: Etai Lev Ran <elevran@gmail.com> * fix(ci): report the specific blocking label found Signed-off-by: Etai Lev Ran <elevran@gmail.com> * fix(ci): simplify blocking-label error message Signed-off-by: Etai Lev Ran <elevran@gmail.com> --------- Signed-off-by: Etai Lev Ran <elevran@gmail.com>
1 parent ac78a25 commit 85e1ee2

1 file changed

Lines changed: 17 additions & 6 deletions

File tree

.github/workflows/pr-hold-gate.yml

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Fails a required check while a hold label is present, so the `hold` label and
2-
# the release branch auto-hold (`do-not-merge/hold`) block GitHub native
3-
# auto-merge. Re-runs on label changes.
1+
# Fails a required check while a hold label is present, so /hold (label `hold`)
2+
# and the release-branch auto-hold (label `do-not-merge/hold`) block
3+
# GitHub-native auto-merge. Re-runs on label changes.
44

55
name: Hold gate
66

@@ -10,13 +10,24 @@ on:
1010

1111
permissions:
1212
contents: read
13+
pull-requests: read
1314

1415
jobs:
1516
hold:
1617
runs-on: ubuntu-latest
1718
steps:
1819
- name: Block merge while held
19-
if: contains(github.event.pull_request.labels.*.name, 'hold') || contains(github.event.pull_request.labels.*.name, 'do-not-merge/hold')
20+
env:
21+
GH_TOKEN: ${{ github.token }}
22+
PR_URL: ${{ github.event.pull_request.html_url }}
2023
run: |
21-
echo "::error::A hold label is present (hold or do-not-merge/hold). Remove the label to allow merge."
22-
exit 1
24+
blocking_labels=(hold do-not-merge/hold)
25+
26+
# fetch current labels
27+
labels=$(gh pr view "$PR_URL" --json labels -q '.labels[].name')
28+
for label in "${blocking_labels[@]}"; do
29+
if grep -qxF "$label" <<< "$labels"; then
30+
echo "::error::Blocking label '$label' is present. Remove it to allow merge (e.g., /hold cancel for hold)."
31+
exit 1
32+
fi
33+
done

0 commit comments

Comments
 (0)