Skip to content

Commit

Permalink
Add workflow to prevent merging a PR when the NO-MERGE label is app…
Browse files Browse the repository at this point in the history
…lied (dotnet#111940)

* Add workflow to prevent merging a PR when the `NO-MERGE` label is applied.
* Fix backtick bug in check-service-labels echo too.
  • Loading branch information
carlossanlop authored Jan 29, 2025
1 parent f71255e commit 87e9f1d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
25 changes: 25 additions & 0 deletions .github/workflows/check-no-merge-label.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: check-no-merge-label

permissions:
pull-requests: read

on:
pull_request:
types: [opened, edited, reopened, labeled, unlabeled, synchronize]
branches:
- 'main'
- 'release/**'

jobs:
check-labels:
runs-on: ubuntu-latest
steps:
- name: Check 'NO-MERGE' label
run: |
echo "Merging permission is disabled when the 'NO-MERGE' label is applied."
if [ "${{ contains(github.event.pull_request.labels.*.name, 'NO-MERGE') }}" = "false" ]; then
exit 0
else
echo "::error:: The 'NO-MERGE' label was applied to the PR. Merging is disabled."
exit 1
fi
2 changes: 1 addition & 1 deletion .github/workflows/check-service-labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
steps:
- name: Check 'Servicing-approved' label
run: |
echo "Merging permission is enabled for servicing PRs when the `Servicing-approved` label is applied."
echo "Merging permission is enabled for servicing PRs when the 'Servicing-approved' label is applied."
if [ "${{ contains(github.event.pull_request.labels.*.name, 'Servicing-approved') }}" = "true" ]; then
exit 0
else
Expand Down

0 comments on commit 87e9f1d

Please sign in to comment.