TmpMenu/.github/workflows/autocloser.yml
GeopJr bb8703520a chore(ci): rewrite autocloser response (#112)
chore(issue_template): add a comment for clarity to bug_report
2022-03-14 19:53:28 +01:00

39 lines
1.4 KiB
YAML

name: Autocloser
on:
issues:
types: [opened]
jobs:
autoclose:
runs-on: ubuntu-latest
name: Autocloser
steps:
- name: Autoclose issue that does not follow template
uses: actions/github-script@v6
env:
message: "this issue was automatically closed because it did not follow the issue template.\n\nA moderator will reopen the issue if it is valid, otherwise it will be tagged with \"invalid\" afterwards."
pattern: "(.*Describe the bug.*To Reproduce.*Expected behavior.*Logs.*Build.*)|(.*Is your feature request related to a problem. Please describe..*Describe the solution you'd like.*Provide Reasoning.*)"
with:
script: |
const { message, pattern } = process.env
if (!context.payload.sender) return;
const body = context.payload.issue.body;
const templateRegex = new RegExp(pattern, "s")
if (!body || !body.match(templateRegex)) {
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `@${context.payload.sender.login}, ${message}`
})
github.rest.issues.update({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
state: 'closed'
})
}