mirror of
https://gitee.com/layui/layui.git
synced 2025-04-05 17:38:02 +08:00
ci: 优化 issue 被创建和被编辑时的 action 校验逻辑 (#1496)
* ci(issue): 增加 duplicate 标签的定时关闭任务 * docs(issue): 优化 discussion 标签文案 * ci: 优化 issue 被创建和被编辑时的 action 校验逻辑 * refactor(issue-opened): 简化语句
This commit is contained in:
parent
02c534349c
commit
6abb1eedd8
8
.github/workflows/issue-close-require.yml
vendored
8
.github/workflows/issue-close-require.yml
vendored
@ -22,9 +22,15 @@ jobs:
|
||||
inactive-day: 3
|
||||
body: |
|
||||
由于超过 3 天仍未收到相关重现或其他更多信息,该 issue 已被自动关闭。
|
||||
- name: Close issues with inactive days of 3
|
||||
uses: actions-cool/issues-helper@v3
|
||||
with:
|
||||
actions: 'close-issues'
|
||||
labels: 'duplicate'
|
||||
inactive-day: 3
|
||||
- name: Close issues with inactive days of 7
|
||||
uses: actions-cool/issues-helper@v3
|
||||
with:
|
||||
actions: 'close-issues'
|
||||
labels: 'compatibility,resolved,unrelated,usage'
|
||||
labels: 'compatibility,resolved,usage'
|
||||
inactive-day: 7
|
||||
|
2
.github/workflows/issue-labeled.yml
vendored
2
.github/workflows/issue-labeled.yml
vendored
@ -63,7 +63,7 @@ jobs:
|
||||
actions: 'create-comment,close-issue'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
body: |
|
||||
@${{ github.event.issue.user.login }} 你好,Issue 一般只接受「Bug 报告」和「功能请求」,而您的议题涉及到如何使用、功能疑惑或其他业务相关的问题,这并不适合作为 Issue 讨论。建议您通过以下方式寻求解决方案:
|
||||
@${{ github.event.issue.user.login }} 你好,Issue 只接受「Bug 报告」和「功能请求」,而您的议题涉及到如何使用、功能疑惑或其他业务相关的问题,这并不适合作为 Issue 讨论。建议您通过以下方式寻求解决方案:
|
||||
- 仔细查阅 Layui 官方文档:https://layui.dev
|
||||
- 通过其他技术社区搜索相关资料、或充分利用当前主流的人工智能大模型
|
||||
- [Discussions](https://github.com/layui/layui/discussions)
|
||||
|
33
.github/workflows/issue-opened.yml
vendored
33
.github/workflows/issue-opened.yml
vendored
@ -1,4 +1,4 @@
|
||||
name: Issue opened
|
||||
name: Issue Opened
|
||||
|
||||
on:
|
||||
issues:
|
||||
@ -31,24 +31,33 @@ jobs:
|
||||
issue_number: context.issue.number,
|
||||
};
|
||||
|
||||
const issue = context.payload.issue;
|
||||
const issueBody = issue.body;
|
||||
const requiredString = "layui-issue-template";
|
||||
const isCreatedByBot = context.payload.sender.type === 'Bot';
|
||||
const isValid = issueBody.includes(requiredString);
|
||||
const payload = context.payload;
|
||||
const isCreatedByBot = payload.sender.type === 'Bot';
|
||||
const issue = payload.issue;
|
||||
const isValid = issue.body?.includes('layui-issue-template');
|
||||
|
||||
// 跳过 closed 状态的 issues
|
||||
if (issue.state === 'closed') {
|
||||
return console.log('Issue is closed.');
|
||||
}
|
||||
|
||||
// 若修改的不是内容,则不必校验
|
||||
if (payload.action === 'edited') {
|
||||
if (payload.changes && !payload.changes.body.from) {
|
||||
return console.log('Edited fields exclude "body".');
|
||||
}
|
||||
}
|
||||
|
||||
// 不符合规则或由机器人创建
|
||||
if (!isValid || isCreatedByBot) {
|
||||
github.rest.issues.createComment({
|
||||
...config,
|
||||
body: `@${context.payload.sender.login} 你好,为了提升沟通效率,我们对 Issue 制定了严格的要求,你的 Issue 因不符合规定而被自动关闭。
|
||||
建议您在下次创建 Issue 时,遵循相应规范和社区行为准则。谢谢。\n > ${process.env.CONTRIBUTING}`
|
||||
});
|
||||
if (isCreatedByBot || !isValid) {
|
||||
if (!isCreatedByBot) {
|
||||
github.rest.issues.createComment({
|
||||
...config,
|
||||
body: `@${payload.sender.login} 你好,为了提升沟通效率,我们对 Issue 制定了严格的要求,你的 Issue 因不符合规定而被自动关闭。
|
||||
建议您在下次创建 Issue 时,遵循相应规范和社区行为准则。谢谢。\n > ${process.env.CONTRIBUTING}`
|
||||
});
|
||||
}
|
||||
// 给 issue 添加指定标签和关闭
|
||||
github.rest.issues.addLabels({
|
||||
...config,
|
||||
labels: ['invalid']
|
||||
|
Loading…
Reference in New Issue
Block a user