Skip to content

Commit 30563dd

Browse files
authored
ci: block merge when PR is labeled 'do not merge'- #572 (#754)
* ci: block merge when PR carries 'Do not merge' label ci: make Do-not-merge label check case-insensitive ci: standardize block-merge-label error message * fix(ci): skip pr job on label-only events * fix(ci): drop token permissions from block-merge-label
1 parent 4b82067 commit 30563dd

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

‎.github/workflows/ci.yml‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: ForgeRock Pull Request CI
22
on:
33
pull_request:
4+
types: [opened, synchronize, reopened, labeled, unlabeled]
45

56
env:
67
NX_CLOUD_ENCRYPTION_KEY: ${{ secrets.NX_CLOUD_ENCRYPTION_KEY }}
@@ -14,8 +15,21 @@ concurrency:
1415
cancel-in-progress: true
1516

1617
jobs:
18+
block-merge-label:
19+
runs-on: ubuntu-latest
20+
permissions: {}
21+
steps:
22+
- name: Fail if "Do not merge" label present
23+
env:
24+
LABELS: ${{ toJSON(github.event.pull_request.labels.*.name) }}
25+
run: |
26+
if echo "$LABELS" | tr '[:upper:]' '[:lower:]' | grep -q '"do not merge"'; then
27+
echo "::error::Merge blocked: PR is labeled 'do not merge'."
28+
exit 1
29+
fi
30+
1731
pr:
18-
if: ${{github.event.pull_request.head.repo.full_name == github.repository}}
32+
if: ${{github.event.pull_request.head.repo.full_name == github.repository && !contains(fromJSON('["labeled", "unlabeled"]'), github.event.action)}}
1933
runs-on: ubuntu-latest
2034
timeout-minutes: 20
2135
permissions:

0 commit comments

Comments
 (0)