feat(Actions): autoclose issues that do not follow template (#85)

This commit is contained in:
GeopJr 2022-03-04 20:01:05 +02:00 committed by GitHub
parent cef53a2877
commit 5722c74fa1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

38
.github/workflows/autocloser.yml vendored Normal file
View File

@ -0,0 +1,38 @@
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\nIf you believe this is an error, please re-open it!"
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'
})
}