-
Notifications
You must be signed in to change notification settings - Fork 31
66 lines (60 loc) · 2.07 KB
/
label_invalid_prs.yaml
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
name: Label invalid database PRs
on:
workflow_run:
workflows: ["Check derivatives change"]
types:
- completed
permissions:
contents: read
pull-requests: write
jobs:
labelInvalidPRs:
runs-on: ubuntu-latest
name: Add/Remove 'invalid' label from trigger PR
if: github.event.workflow_run.event == 'pull_request'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download artifact
uses: dawidd6/action-download-artifact@v2
with:
name: check_derivatives_change
workflow: check_derivatives_change.yml
run_id: ${{github.event.workflow_run.id }}
- name: Retrieve trigger PR issue number from artifacts
id: changed
run: |
issue_number=`cat issue_number`
echo "issue_number=${issue_number}" >> "${GITHUB_OUTPUT}"
- name: Add 'invalid' label if trigger PR check failed
if: github.event.workflow_run.conclusion == 'failure'
uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: ${{ steps.changed.outputs.issue_number }},
labels: ['invalid']
})
- name: Remove 'invalid' label if trigger PR check was successful
if: github.event.workflow_run.conclusion == 'success'
uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
try {
await github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: ${{ steps.changed.outputs.issue_number }},
name: 'invalid'
});
} catch (err) {
if (err.status === 404 && err.message === "Label does not exist") {
console.log("Label not found");
} else {
throw err;
}
}