Skip to content

Commit 17d2bd9

Browse files
committed
ci: Fix DNM action
The action fails even when there is no DNM label. Signed-off-by: Chaitanya Tata <[email protected]>
1 parent 0f3aad9 commit 17d2bd9

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

.github/workflows/dnm.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,22 @@ on:
66

77
jobs:
88
do-not-merge:
9-
if: ${{ contains(github.event.*.labels.*.name, 'DNM') }}
109
name: Prevent Merging
1110
runs-on: ubuntu-24.04
1211
steps:
13-
- name: Check for label
12+
- name: Check for DNM label
13+
uses: actions/github-script@60a0d83039c725a5ff217e4aa4b5cc5170e1c8d7 # v7.0.1
14+
id: check-label
15+
with:
16+
script: |
17+
const labels = context.payload.pull_request.labels || [];
18+
const labelNames = labels.map(l => l.name);
19+
const hasDnm = labelNames.includes('DNM');
20+
core.setOutput('has_dnm', hasDnm);
21+
return hasDnm;
22+
23+
- name: Fail if DNM label exists
24+
if: steps.check-label.outputs.has_dnm == 'true'
1425
run: |
1526
echo "Pull request is labeled as 'DNM'"
1627
echo "This workflow fails so that the pull request cannot be merged"

0 commit comments

Comments
 (0)