-
Notifications
You must be signed in to change notification settings - Fork 4.2k
78 lines (75 loc) · 3.08 KB
/
test_labeler.yml
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
67
68
69
70
71
72
73
74
75
76
77
78
name: Apply Test Labels
on:
workflow_run:
workflows: ["astyle", "JSON Validation", "General build matrix"]
types: [completed]
jobs:
labeling:
if: github.repository == 'CleverRaven/Cataclysm-DDA'
runs-on: ubuntu-latest
steps:
- name: setLabel
id: setLabel
run: |
if [[ "${{ github.event.workflow_run.name }}" == "astyle" ]]; then
echo "label=astyled" >> $GITHUB_OUTPUT
fi
if [[ "${{ github.event.workflow_run.name }}" == "JSON Validation" ]]; then
echo "label=json-styled" >> $GITHUB_OUTPUT
fi
if [[ "${{ github.event.workflow_run.name }}" == "General build matrix" ]]; then
echo "label=BasicBuildPassed" >> $GITHUB_OUTPUT
fi
- name: Download success artifact from basic build
if: ${{ github.event.workflow_run.name == 'General build matrix' }}
uses: dawidd6/[email protected]
with:
workflow: ${{ github.event.workflow_run.name }}
run_id: ${{ github.event.workflow_run.id }}
name: basic-build
- name: set-basic-build-success
id: set-basic-build-success
run: echo "basic-build-success=$( cat basic-build )" >> $GITHUB_OUTPUT
- name: Download pr id artifact
uses: dawidd6/[email protected]
with:
workflow: ${{ github.event.workflow_run.name }}
run_id: ${{ github.event.workflow_run.id }}
name: pull_request_id
- name: set-pr-id
id: set-pr-id
run: echo "pr-id=$( cat pull_request_id )" >> $GITHUB_OUTPUT
- name: set-label
if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.conclusion != 'skipped' || steps.set-basic-build-success.outputs.basic-build-success == 'true' }}
uses: actions/github-script@v7
with:
script: |
if ('${{ steps.set-pr-id.outputs.pr-id }}'.trim().length == 0) {
console.log("The PR ID artifact does not contain a pull request number.")
} else {
github.rest.issues.addLabels({
issue_number: ${{ steps.set-pr-id.outputs.pr-id }},
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['${{ steps.setLabel.outputs.label }}']
})
}
- name: remove-label
if: ${{ github.event.workflow_run.conclusion == 'failure' && steps.set-basic-build-success.outputs.basic-build-success != 'true' }}
uses: actions/github-script@v7
with:
script: |
if ('${{ steps.set-pr-id.outputs.pr-id }}'.trim().length == 0) {
console.log("The PR ID artifact does not contain a pull request number.")
} else {
try {
github.rest.issues.removeLabel({
issue_number: ${{ steps.set-pr-id.outputs.pr-id }},
owner: context.repo.owner,
repo: context.repo.repo,
name: '${{ steps.setLabel.outputs.label }}'
})
} catch (e) {
console.log(e)
}
}