forked from PCL-Community/PCL2-CE
-
Notifications
You must be signed in to change notification settings - Fork 0
48 lines (43 loc) · 1.45 KB
/
labels.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
name: Manage Labels on Issue Close
on:
issues:
types: [closed]
jobs:
manage-labels:
runs-on: ubuntu-latest
steps:
- name: Handle labels based on close reason
uses: actions/github-script@v6
with:
github-token: ${{ secrets.BOT }}
script: |
const { issue, repository } = context.payload;
const labelsToRemove = ['⭕ 等待处理', '🚧 正在处理'];
const closedReason = issue.state_reason;
// 移除旧标签
for (const label of labelsToRemove) {
try {
await github.rest.issues.removeLabel({
owner: repository.owner.login,
repo: repository.name,
issue_number: issue.number,
name: label
});
} catch (error) {
if (error.status !== 404) throw error;
}
}
// 根据关闭原因添加新标签
const reasonMapping = {
'completed': '👌 完成',
'not_planned': '❌ 忽略',
'duplicate': '❌ 重复'
};
if (reasonMapping[closedReason]) {
await github.rest.issues.addLabels({
owner: repository.owner.login,
repo: repository.name,
issue_number: issue.number,
labels: [reasonMapping[closedReason]]
});
}