-
Notifications
You must be signed in to change notification settings - Fork 2
74 lines (64 loc) · 2.44 KB
/
reopen-issue.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
name: Reopen and Update Stale Issues
on:
workflow_dispatch: # 手动触发
jobs:
reopen_stale_issues:
runs-on: ubuntu-latest
permissions:
issues: write
contents: read
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Fetch Closed Issues with lifecycle/stale Label
id: fetch_issues
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const issues = await github.paginate(github.rest.issues.listForRepo, {
owner: context.repo.owner,
repo: context.repo.repo,
state: 'closed',
labels: 'lifecycle/stale',
per_page: 100
});
const issueNumbers = issues
.filter(issue => !issue.pull_request) // 排除PR
.map(issue => issue.number);
console.log(`Fetched issues: ${issueNumbers}`);
return { issue_numbers: issueNumbers.join(',') };
- name: Set issue numbers
run: echo "ISSUE_NUMBERS=${{ steps.fetch_issues.outputs.issue_numbers }}" >> $GITHUB_ENV
- name: Reopen Issues
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const issueNumbers = process.env.ISSUE_NUMBERS.split(',');
for (const issue_number of issueNumbers) {
// Reopen the issue
await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: parseInt(issue_number, 10),
state: 'open'
});
console.log(`Reopened issue #${issue_number}`);
}
- name: Remove lifecycle/stale Label
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const issueNumbers = process.env.ISSUE_NUMBERS.split(',');
for (const issue_number of issueNumbers) {
// Remove the lifecycle/stale label
await github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: parseInt(issue_number, 10),
name: 'lifecycle/stale'
});
console.log(`Removed label 'lifecycle/stale' from issue #${issue_number}`);
}