From 3d3b08e76a03018440994905263cc122349529e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20S=C3=A1nchez=20L=C3=B3pez?= <1175054+carlossanlop@users.noreply.github.com> Date: Tue, 28 Jan 2025 17:59:38 -0800 Subject: [PATCH 1/3] Add workflow to prevent merging a PR when the `NO-MERGE` label is applied. --- .github/workflows/check-no-merge-label.yml | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .github/workflows/check-no-merge-label.yml diff --git a/.github/workflows/check-no-merge-label.yml b/.github/workflows/check-no-merge-label.yml new file mode 100644 index 00000000000000..1a28d925cc268a --- /dev/null +++ b/.github/workflows/check-no-merge-label.yml @@ -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') }}" = "true" ]; then + exit 0 + else + echo "::error:: The 'NO-MERGE' label was applied to the PR. Merging is disabled." + exit 1 + fi From e0a0140dd925f6da49a0a01bc1cc56764bcef05e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20S=C3=A1nchez=20L=C3=B3pez?= <1175054+carlossanlop@users.noreply.github.com> Date: Wed, 29 Jan 2025 08:58:33 -0800 Subject: [PATCH 2/3] Invert condition --- .github/workflows/check-no-merge-label.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check-no-merge-label.yml b/.github/workflows/check-no-merge-label.yml index 1a28d925cc268a..1c01c2f7324175 100644 --- a/.github/workflows/check-no-merge-label.yml +++ b/.github/workflows/check-no-merge-label.yml @@ -16,8 +16,8 @@ jobs: 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') }}" = "true" ]; then + 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." From 7c2a39d3cfa4c72008872d40ad09eba576a18bb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20S=C3=A1nchez=20L=C3=B3pez?= <1175054+carlossanlop@users.noreply.github.com> Date: Wed, 29 Jan 2025 08:58:47 -0800 Subject: [PATCH 3/3] Fix backtick bug in check-service-labels echo. --- .github/workflows/check-service-labels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check-service-labels.yml b/.github/workflows/check-service-labels.yml index 5261cc165ee128..2d85e4d278a393 100644 --- a/.github/workflows/check-service-labels.yml +++ b/.github/workflows/check-service-labels.yml @@ -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