Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions .github/workflows/pr-hold-gate.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Fails a required check while a hold label is present, so the `hold` label and
# the release branch auto-hold (`do-not-merge/hold`) block GitHub native
# auto-merge. Re-runs on label changes.
# Fails a required check while a hold label is present, so /hold (label `hold`)
# and the release-branch auto-hold (label `do-not-merge/hold`) block
# GitHub-native auto-merge. Re-runs on label changes.

name: Hold gate

Expand All @@ -10,13 +10,24 @@ on:

permissions:
contents: read
pull-requests: read

jobs:
hold:
runs-on: ubuntu-latest
steps:
- name: Block merge while held
if: contains(github.event.pull_request.labels.*.name, 'hold') || contains(github.event.pull_request.labels.*.name, 'do-not-merge/hold')
env:
GH_TOKEN: ${{ github.token }}
PR_URL: ${{ github.event.pull_request.html_url }}
run: |
echo "::error::A hold label is present (hold or do-not-merge/hold). Remove the label to allow merge."
exit 1
blocking_labels=(hold do-not-merge/hold)

# fetch current labels
labels=$(gh pr view "$PR_URL" --json labels -q '.labels[].name')
for label in "${blocking_labels[@]}"; do
if grep -qxF "$label" <<< "$labels"; then
echo "::error::Blocking label '$label' is present. Remove it to allow merge (e.g., /hold cancel for hold)."
exit 1
fi
done
Loading