Skip to content

Commit 422ff12

Browse files
authored
Merge branch 'mit-han-lab:main' into main
2 parents c5a3b3b + ec55886 commit 422ff12

File tree

2 files changed

+70
-4
lines changed

2 files changed

+70
-4
lines changed

.github/workflows/close-inactive-issues.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ name: Close Inactive Issues
33
on:
44
schedule:
55
- cron: '0 0 * * *'
6-
workflow_dispatch:
76
permissions:
87
issues: write
98
contents: read
@@ -17,7 +16,7 @@ jobs:
1716
with:
1817
github-token: ${{secrets.GITHUB_TOKEN}}
1918
script: |
20-
const sixtyDaysAgo = new Date(Date.now() - 60 * 24 * 60 * 60 * 1000);
19+
const thirtyDaysAgo = new Date(Date.now() - 30 * 24 * 60 * 60 * 1000);
2120
2221
const [owner, repo] = process.env.GITHUB_REPOSITORY.split('/');
2322
console.log(`Owner: ${owner}, Repo: ${repo}`);
@@ -57,7 +56,7 @@ jobs:
5756
console.log(`Skipping issue #${issue.number} as it's marked as 'good first issue'`);
5857
continue;
5958
}
60-
if (new Date(issue.updated_at) < sixtyDaysAgo) {
59+
if (new Date(issue.updated_at) < thirtyDaysAgo) {
6160
try {
6261
await github.rest.issues.update({
6362
owner,
@@ -70,7 +69,7 @@ jobs:
7069
owner,
7170
repo,
7271
issue_number: issue.number,
73-
body: 'This issue has been automatically closed due to 60-day inactivity. Please feel free to reopen it if needed.'
72+
body: 'This issue has been automatically closed due to 30-day inactivity. Please feel free to reopen it with \`/reopen\` if needed.'
7473
});
7574
console.log(`Closed issue #${issue.number} due to inactivity.`);
7675
} catch (error) {
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Reopen Issue on /reopen Command
2+
on:
3+
issue_comment:
4+
types: [created]
5+
permissions:
6+
issues: write
7+
contents: read
8+
jobs:
9+
reopen-issue:
10+
if: github.repository == 'mit-han-lab/ComfyUI-nunchaku'
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Check if comment is /reopen by issue creator and reopen
14+
uses: actions/github-script@v6
15+
with:
16+
github-token: ${{ secrets.GITHUB_TOKEN }}
17+
script: |
18+
const commentBody = context.payload.comment.body.trim();
19+
const issueNumber = context.payload.issue.number;
20+
const commentAuthor = context.payload.comment.user.login;
21+
const issueAuthor = context.payload.issue.user.login;
22+
23+
if (commentBody === '/reopen') {
24+
if (commentAuthor === issueAuthor) {
25+
// Only proceed if issue is currently closed
26+
if (context.payload.issue.state === 'closed') {
27+
const [owner, repo] = process.env.GITHUB_REPOSITORY.split('/');
28+
try {
29+
await github.rest.issues.update({
30+
owner,
31+
repo,
32+
issue_number: issueNumber,
33+
state: 'open',
34+
});
35+
36+
// Remove 'inactive' label if present
37+
const labels = context.payload.issue.labels.map(label => label.name);
38+
if (labels.includes('inactive')) {
39+
const newLabels = labels.filter(label => label !== 'inactive');
40+
await github.rest.issues.update({
41+
owner,
42+
repo,
43+
issue_number: issueNumber,
44+
labels: newLabels,
45+
});
46+
}
47+
48+
await github.rest.issues.createComment({
49+
owner,
50+
repo,
51+
issue_number: issueNumber,
52+
body: `Issue reopened by @${commentAuthor} via \`/reopen\` command.`,
53+
});
54+
55+
console.log(`Reopened issue #${issueNumber} by request of issuer.`);
56+
} catch (error) {
57+
console.error(`Failed to reopen issue #${issueNumber}: ${error.message}`);
58+
}
59+
} else {
60+
console.log(`Issue #${issueNumber} is already open.`);
61+
}
62+
} else {
63+
console.log(`Commenter @${commentAuthor} is not the issue creator @${issueAuthor}, ignoring.`);
64+
}
65+
} else {
66+
console.log(`Comment is not /reopen, ignoring.`);
67+
}

0 commit comments

Comments
 (0)