layui/.github/workflows/issue-opened.yml

70 lines
2.3 KiB
YAML
Raw Normal View History

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 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 (isCreatedByBot || !isValid) {
if (!isCreatedByBot) {
github.rest.issues.createComment({
...config,
body: `@${payload.sender.login} 你好,为了提升沟通效率,我们对 Issue 制定了严格的要求,你的 Issue 因不符合规定而被自动关闭。
docs(issue): 优化 bot 回复文案 (#1510) * ci(issue): 增加 duplicate 标签的定时关闭任务 * docs(issue): 优化 discussion 标签文案 * ci: 优化 issue 被创建和被编辑时的 action 校验逻辑 * refactor(issue-opened): 简化语句 * docs(issue): 优化 bot 回复文案 * Squashed commit of the following: commit e5aa6c3a877713ca65007b85191d01c864001d04 Author: morning-star <1453017105@qq.com> Date: Tue Dec 26 22:32:10 2023 +0800 feat(transfer): 新增 `dblclick` 选项 (#1491) * feat(transfer): 新增 `dblclick` 选项 * style(transfer): 优化代码书写风格 --------- Co-authored-by: 贤心 <3277200+sentsim@users.noreply.github.com> commit ed3bab52e56066dc2c6ec938cd3115be4483d4a0 Author: morning-star <1453017105@qq.com> Date: Mon Dec 25 14:53:55 2023 +0800 chore(select): 优化搜索面板打开逻辑 (#1498) commit 5db18c6f00fbee775ea466b24a4057ec7dea1a24 Author: 贤心 <3277200+sentsim@users.noreply.github.com> Date: Mon Dec 25 14:52:52 2023 +0800 docs: 优化 issue 模板提示文案 (#1500) commit 567a1e70c1da056eb7e5dfd583120098b0e3fd3a Author: morning-star <1453017105@qq.com> Date: Mon Dec 25 13:22:50 2023 +0800 feat(upload): 加强 data 选项的函数写法,支持获取文件相关数据 (#1494) close https://gitee.com/layui/layui/issues/I8JAC1 commit 6abb1eedd89313c7f1b6768b9bb6eca966010a53 Author: 贤心 <3277200+sentsim@users.noreply.github.com> Date: Mon Dec 25 12:15:51 2023 +0800 ci: 优化 issue 被创建和被编辑时的 action 校验逻辑 (#1496) * ci(issue): 增加 duplicate 标签的定时关闭任务 * docs(issue): 优化 discussion 标签文案 * ci: 优化 issue 被创建和被编辑时的 action 校验逻辑 * refactor(issue-opened): 简化语句
2023-12-26 22:58:03 +08:00
建议你在下次创建 Issue 时,遵循相应规范和社区行为准则。谢谢。\n > ${process.env.CONTRIBUTING}`
});
}
// 给 issue 添加指定标签和关闭
github.rest.issues.addLabels({
...config,
labels: ['invalid']
});
github.rest.issues.update({
...config,
state: 'closed'
});
}