FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
processing/.github/workflows/lock.yml at master · processing/processing · GitHub
processing
processing
Repository navigation
Code
Issues
Pull requests
Actions
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
processing
/
.github
/
workflows
/
lock.yml
Copy path
View runs
More file actions
More file actions
Latest commit
History
History
History
129 lines (107 loc) · 4.32 KB
Breadcrumbs
processing
/
.github
/
workflows
/
lock.yml
Copy path
File metadata and controls
129 lines (107 loc) · 4.32 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name
:
Close old issues and pull requests
on
:
schedule
:
-
cron
:
'
0 6 * * *
'
workflow_dispatch
:
concurrency
:
group
:
close-old-threads
cancel-in-progress
:
false
permissions
:
issues
:
write
pull-requests
:
write
jobs
:
close-old-threads
:
runs-on
:
ubuntu-latest
steps
:
-
uses
:
actions/github-script@v9
with
:
script
:
|
const cutoffDays = 30;
const exemptLabels = ['keep-open'];
const cutoff = new Date();
cutoff.setDate(cutoff.getDate() - cutoffDays);
const closeIssueMessage = [
'This issue has been automatically closed and locked.',
'',
'Processing 3.x is no longer actively developed. Since January 2020, development moved to the Processing 4 repository.',
'',
"If this issue is still relevant to Processing 4, we'd love to hear from you. Please open a new issue at:",
'https://github.com/processing/processing4/issues/new/choose',
'',
'Thank you for helping improve Processing.'
].join('\n');
const closePrMessage = [
'This pull request has been automatically closed and locked.',
'',
'Processing 3.x is no longer actively developed. Since January 2020, development moved to the Processing 4 repository.',
'',
"If you'd still like to contribute this work, please open an issue in the Processing 4 repository to discuss it first:",
'https://github.com/processing/processing4/issues/new/choose',
'',
'Thank you for your contribution.'
].join('\n');
async function closeThread(thread) {
const isPr = Boolean(thread.pull_request);
if (isPr) {
await github.rest.pulls.update({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: thread.number,
state: 'closed'
});
} else {
await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: thread.number,
state: 'closed',
state_reason: 'not_planned'
});
}
}
const threads = await github.paginate(github.rest.issues.listForRepo, {
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
per_page: 100,
sort: 'updated',
direction: 'asc'
});
for (const thread of threads) {
try {
const updatedAt = new Date(thread.updated_at);
if (updatedAt > cutoff) {
break;
}
const labels = thread.labels.map(label =>
typeof label === 'string' ? label : label.name
);
const isExempt = labels.some(label => exemptLabels.includes(label));
if (isExempt) {
console.log(`Skipping #${thread.number}: exempt label.`);
continue;
}
const isPr = Boolean(thread.pull_request);
const body = isPr ? closePrMessage : closeIssueMessage;
await closeThread(thread);
if (thread.locked) {
console.log(`Closed #${thread.number}: already locked, so no comment was added.`);
continue;
}
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: thread.number,
body
});
await github.rest.issues.lock({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: thread.number,
lock_reason: 'resolved'
});
console.log(`Closed and locked #${thread.number}.`);
} catch (error) {
console.log(`Failed on #${thread.number}: ${error.status || 'unknown status'} ${error.message}`);
}
}
Back
|
FazBrowse Home
|
New Git URL