-
-
Notifications
You must be signed in to change notification settings - Fork 3
100 lines (89 loc) · 3.13 KB
/
merge.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
name: Set Labels on Pull Request
on:
pull_request:
types:
- closed
permissions:
contents: read
issues: write
pull-requests: write
discussions: write
jobs:
set-label-on-merge:
runs-on: ubuntu-latest
steps:
- name: Set Label on Merge
if: ${{ github.event.pull_request.merged }}
# if: steps.pr_outcome.outputs.pr_outcome == 'true'
uses: actions/github-script@v7.0.1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const prNumber = context.payload.pull_request.number;
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
labels: ['PR: released']
});
const pullRequestLabels = await github.rest.issues.listLabelsOnIssue({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber
});
const labelNames = pullRequestLabels.data.map(label => label.name);
if (labelNames.includes('in progress')) {
await github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
name: 'in progress'
});
}
if (labelNames.includes('wait')) {
await github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
name: 'wait'
});
}
set-label-on-reject:
runs-on: ubuntu-latest
steps:
- name: Set Label on Reject
# if: steps.pr_outcome.outputs.pr_outcome != 'true'
if: ${{ !github.event.pull_request.merged }}
uses: actions/github-script@v7.0.1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const prNumber = context.payload.pull_request.number;
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
name: 'PR: rejected'
});
const pullRequestLabels = await github.rest.issues.listLabelsOnIssue({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber
});
const labelNames = pullRequestLabels.data.map(label => label.name);
if (labelNames.includes('in progress')) {
await github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
name: 'in progress'
});
}
if (labelNames.includes('wait')) {
await github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
name: 'wait'
});
}