-
Notifications
You must be signed in to change notification settings - Fork 157
34 lines (29 loc) · 1.08 KB
/
do_not_merge.yml
File metadata and controls
34 lines (29 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
name: Do Not Merge
on:
pull_request:
types: [synchronize, opened, reopened, labeled, unlabeled]
jobs:
do-not-merge:
name: Blocked by label
runs-on: ubuntu-latest
steps:
- name: Fail if 'status:do-not-merge' label is present
id: check-label
env:
LABELS_JSON: ${{ toJson(github.event.pull_request.labels) }}
run: |
set -x
# The multiline string needs to be reformed into 'real' JSON again
MATCH=$(jq -Rs 'fromjson | map(select(.name == "status:do-not-merge")) | length' <<<"$LABELS_JSON")
if [ "$MATCH" -gt 0 ]; then
echo "Label 'status:do-not-merge' is present. Failing the job."
echo "found=true" >> "$GITHUB_OUTPUT"
else
echo "Label 'status:do-not-merge' is NOT present. Passing."
echo "found=false" >> "$GITHUB_OUTPUT"
fi
- name: Fail if label is present
if: steps.check-label.outputs.found == 'true'
run: |
echo "❌ Label 'status:do-not-merge' is present. Failing the job."
exit 1