Skip to content

Commit bffddd9

Browse files
authored
Add label if pre-commit passes (#12527)
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
1 parent d84cef7 commit bffddd9

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Add label on pre-commit success
2+
on:
3+
workflow_run:
4+
workflows: [pre-commit]
5+
types: [requested, completed]
6+
jobs:
7+
add-label-on-pre-commit-success:
8+
runs-on: ubuntu-latest
9+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
10+
steps:
11+
- name: Add label
12+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
13+
with:
14+
script: |
15+
github.rest.issues.addLabels({
16+
owner: context.repo.owner,
17+
repo: context.repo.repo,
18+
issue_number: context.issue.number,
19+
labels: ['pre-commit-passed']
20+
})
21+
env:
22+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23+
remove-label-on-pre-commit-not-success:
24+
runs-on: ubuntu-latest
25+
if: ${{ github.event.workflow_run.conclusion != 'success' }}
26+
steps:
27+
- name: Remove label
28+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
29+
with:
30+
script: |
31+
github.rest.issues.removeLabels({
32+
owner: context.repo.owner,
33+
repo: context.repo.repo,
34+
issue_number: context.issue.number,
35+
labels: ['pre-commit passed']
36+
})
37+
env:
38+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)