Skip to content

Commit 03ffe1b

Browse files
committed
ci: Add workflow to prevent merging PRs with 'dont-merge' label
Sometimes, it is useful to have an option to prevent maintainers from merging a Pull Request when reviews are in and all checks are green but merging should be deferred for whatever reason. This commit adds a workflow that fails if a Pull Request has a label containing the substring 'dont-merge' [0]. This mechanism is inspired by what Cilium does with maintainer's little helper [1] and the implementation is based on this blog post from Jesse Squires and Ben Asher [2]. [0] https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/evaluate-expressions-in-workflows-and-actions#contains [1] https://github.com/cilium/github-actions/blob/d6fb4a25efefa0f830dce582af2510eb7eed6397/README.md?plain=1#L55 [2] https://www.jessesquires.com/blog/2021/08/24/useful-label-based-github-actions-workflows/#do-not-merge Signed-off-by: Quentin Monnet <[email protected]>
1 parent 753ae12 commit 03ffe1b

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

.github/workflows/mergeability.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Mergeability
2+
3+
on:
4+
pull_request:
5+
types: [synchronize, opened, reopened, labeled, unlabeled]
6+
7+
jobs:
8+
check-labels:
9+
runs-on: ubuntu-latest
10+
name: Check mergeability based on labels
11+
steps:
12+
- if: ${{ contains(github.event.*.labels.*.name, 'dont-merge') }}
13+
name: Fail test due to 'dont-merge' label presence
14+
run: exit 1
15+
- name: Allow merging
16+
run: exit 0

0 commit comments

Comments
 (0)