mirror of https://github.com/layui/layui
ci(issue): 新增和优化多个 workflow (#1475)
* chore: 增加 issue 模板特定标识 * ci(issue): 修改 issue 不活跃状态天数 * refactor: 修改 Issue Labeled 任务变量名 * style: 段落优化 * ci: 新增 Issue 创建和编辑时的 action * ci: 新增 Issue 关闭时的 actionpull/1479/head
parent
7b5a09b379
commit
1fdc84c498
|
@ -60,5 +60,5 @@ body:
|
||||||
attributes:
|
attributes:
|
||||||
label: 友好承诺
|
label: 友好承诺
|
||||||
options:
|
options:
|
||||||
- label: 我承诺将本着相互尊重、理解和友善的态度进行交流,共同维护 Layui 良好的社区氛围。
|
- label: 我承诺将本着相互尊重、理解和友善的态度进行交流,共同维护 Layui 良好的社区氛围。 <!-- layui-issue-template 请务必严格遵循模板规范 -->
|
||||||
required: true
|
required: true
|
||||||
|
|
|
@ -19,12 +19,12 @@ jobs:
|
||||||
with:
|
with:
|
||||||
actions: 'close-issues'
|
actions: 'close-issues'
|
||||||
labels: 'need reproduce'
|
labels: 'need reproduce'
|
||||||
inactive-day: 5
|
inactive-day: 3
|
||||||
body: |
|
body: |
|
||||||
由于超过 5 天仍未收到相关重现,该 issue 已被自动关闭。
|
由于超过 3 天仍未收到相关重现或其他更多信息,该 issue 已被自动关闭。
|
||||||
- name: resolved
|
- name: Close inactive issues within 7 days
|
||||||
uses: actions-cool/issues-helper@v3
|
uses: actions-cool/issues-helper@v3
|
||||||
with:
|
with:
|
||||||
actions: 'close-issues'
|
actions: 'close-issues'
|
||||||
labels: 'resolved'
|
labels: 'compatibility,discussion,resolved,unrelated,usage'
|
||||||
inactive-day: 3
|
inactive-day: 7
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
name: Issue Closed
|
||||||
|
|
||||||
|
on:
|
||||||
|
issues:
|
||||||
|
types: [closed]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
issue-closed:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
# 追加标签
|
||||||
|
- name: Add labels
|
||||||
|
id: label-check
|
||||||
|
uses: actions/github-script@v7
|
||||||
|
with:
|
||||||
|
github-token: ${{secrets.GITHUB_TOKEN}}
|
||||||
|
script: |
|
||||||
|
const config = {
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
issue_number: context.issue.number,
|
||||||
|
};
|
||||||
|
const issue = await github.rest.issues.get(config);
|
||||||
|
|
||||||
|
// 是否带有 `bug` 标签
|
||||||
|
const hasBugLabel = issue.data.labels.some(label => label.name === 'bug');
|
||||||
|
|
||||||
|
// 对带有 `bug` 标签的 issue 追加 `resolved` 标签,表示 bug 已解决。
|
||||||
|
if (hasBugLabel) {
|
||||||
|
github.rest.issues.addLabels({
|
||||||
|
...config,
|
||||||
|
labels: ['resolved']
|
||||||
|
});
|
||||||
|
}
|
|
@ -17,8 +17,8 @@ jobs:
|
||||||
- name: content template
|
- name: content template
|
||||||
id: template
|
id: template
|
||||||
run: |
|
run: |
|
||||||
DIR_NAME="详见:🍀 [Layui Issue 贡献指南](https://github.com/layui/layui/blob/main/CONTRIBUTING.md)"
|
contribute="详见:🍀 [Layui Issue 贡献指南](https://github.com/layui/layui/blob/main/CONTRIBUTING.md)"
|
||||||
echo "CONTRIBUTING=$DIR_NAME" >> $GITHUB_OUTPUT
|
echo "CONTRIBUTING=$contribute" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: help wanted
|
- name: help wanted
|
||||||
if: github.event.label.name == 'help wanted'
|
if: github.event.label.name == 'help wanted'
|
||||||
|
|
|
@ -0,0 +1,60 @@
|
||||||
|
name: Issue opened
|
||||||
|
|
||||||
|
on:
|
||||||
|
issues:
|
||||||
|
types: [opened, edited]
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
issue-opened:
|
||||||
|
permissions:
|
||||||
|
issues: write
|
||||||
|
pull-requests: write
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: content template
|
||||||
|
id: template
|
||||||
|
run: |
|
||||||
|
contribute="详见:🍀 [Layui Issue 贡献指南](https://github.com/layui/layui/blob/main/CONTRIBUTING.md)"
|
||||||
|
echo "CONTRIBUTING=$contribute" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: check invalid
|
||||||
|
uses: actions/github-script@v7
|
||||||
|
with:
|
||||||
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
script: |
|
||||||
|
const config = {
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
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);
|
||||||
|
|
||||||
|
// 跳过 closed 状态的 issues
|
||||||
|
if (issue.state === 'closed') {
|
||||||
|
return console.log('Issue is closed.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 不符合规则或由机器人创建
|
||||||
|
if (!isValid || isCreatedByBot) {
|
||||||
|
github.rest.issues.createComment({
|
||||||
|
...config,
|
||||||
|
body: `@${context.payload.sender.login} 你好,为了提升沟通效率,我们对 Issue 制定了严格的要求,你的 Issue 因不符合规定而被自动关闭。
|
||||||
|
建议您在下次创建 Issue 时,遵循相应规范和社区行为准则。谢谢。\n > ${process.env.CONTRIBUTING}`
|
||||||
|
});
|
||||||
|
github.rest.issues.addLabels({
|
||||||
|
...config,
|
||||||
|
labels: ['invalid']
|
||||||
|
});
|
||||||
|
github.rest.issues.update({
|
||||||
|
...config,
|
||||||
|
state: 'closed'
|
||||||
|
});
|
||||||
|
}
|
|
@ -1,10 +1,10 @@
|
||||||
|
name: Create Release
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
tags:
|
tags:
|
||||||
- 'v*'
|
- 'v*'
|
||||||
|
|
||||||
name: Create Release
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
name: Create Release
|
name: Create Release
|
||||||
|
|
Loading…
Reference in New Issue