-
Notifications
You must be signed in to change notification settings - Fork 20
[CI/CD] Add a workflow to prevent issue auto closed #207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
8cc4183
3bf3e1f
9be13d9
12ea9b9
6a099ad
c55c42c
460778d
1c82d45
80a2b42
72487b9
307bd97
6faa794
389f52a
d46ab87
2e9c9c1
bcb45ff
211ca01
1f54370
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| name: Prevent Issue Close with not_fixed Label | ||
|
|
||
| on: | ||
| issues: | ||
| types: [closed] | ||
|
|
||
| permissions: | ||
| issues: write | ||
|
|
||
| jobs: | ||
| prevent-close: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Check not_fixed label and reopen if needed | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| const issue = context.payload.issue; | ||
| const labels = issue.labels.map(label => label.name.toLowerCase()); | ||
| const issueNumber = issue.number; | ||
| const owner = context.repo.owner; | ||
| const repo = context.repo.repo; | ||
|
|
||
| // 检查是否存在 not_fixed 标签 | ||
| if (labels.includes('not_fixed')) { | ||
| console.log(`Issue #${issueNumber} has 'not_fixed' label, preventing closure...`); | ||
|
|
||
| // 重新打开 issue | ||
| await github.rest.issues.update({ | ||
| owner: owner, | ||
| repo: repo, | ||
| issue_number: issueNumber, | ||
| state: 'open' | ||
| }); | ||
|
|
||
| // 添加评论说明 | ||
| await github.rest.issues.createComment({ | ||
| owner: owner, | ||
| repo: repo, | ||
| issue_number: issueNumber, | ||
| body: `⚠️ **此 Issue 无法关闭**\n\n该 Issue 带有 \`not_fixed\` 标签,表示问题尚未完全解决。\n\n修复此问题的 PR 可能已经合入,请 @${issue.user.login} 验证后移除 \`not_fixed\` 标签并手动关闭此 Issue。` | ||
| }); | ||
|
Comment on lines
+36
to
+42
|
||
|
|
||
| console.log(`Issue #${issueNumber} has been reopened due to 'not_fixed' label`); | ||
| } else { | ||
| console.log(`Issue #${issueNumber} does not have 'not_fixed' label, allowing closure`); | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The workflow posts a Chinese-only comment body when preventing closure. This repo already splits CN/EN automation by detecting Chinese characters in the issue title (see .github/workflows/issue_auto_reply_cn.yml and issue_auto_reply_en.yml), so English issues will receive an unreadable message here. Consider reusing the same
hasChinesedetection and provide an English message (or a bilingual message) accordingly.