1 changed files with 50 additions and 0 deletions
@ -0,0 +1,50 @@ |
|||||||
|
name: issues |
||||||
|
|
||||||
|
on: |
||||||
|
issues: |
||||||
|
types: [opened] |
||||||
|
|
||||||
|
jobs: |
||||||
|
issues: |
||||||
|
runs-on: ubuntu-latest |
||||||
|
|
||||||
|
steps: |
||||||
|
- uses: actions/checkout@v2 |
||||||
|
|
||||||
|
- run: npm install mdjson |
||||||
|
|
||||||
|
- uses: actions/github-script@v6 |
||||||
|
with: |
||||||
|
github-token: ${{ secrets.GITHUB_TOKEN }} |
||||||
|
script: | |
||||||
|
const fs = require('fs').promises; |
||||||
|
const mdjson = require('mdjson'); |
||||||
|
|
||||||
|
const titles = Object.keys(mdjson(context.payload.issue.body)); |
||||||
|
|
||||||
|
for (let file of await fs.readdir('.github/ISSUE_TEMPLATE')) { |
||||||
|
if (!file.endsWith('.md')) { |
||||||
|
continue; |
||||||
|
} |
||||||
|
|
||||||
|
const template = await fs.readFile(`.github/ISSUE_TEMPLATE/${file}`, 'utf-8'); |
||||||
|
const templateTitles = Object.keys(mdjson(template)); |
||||||
|
|
||||||
|
if (templateTitles.every((title) => titles.includes(title))) { |
||||||
|
process.exit(0); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
await github.rest.issues.createComment({ |
||||||
|
owner: context.issue.owner, |
||||||
|
repo: context.issue.repo, |
||||||
|
issue_number: context.issue.number, |
||||||
|
body: 'This issue is being automatically closed because it does not follow the issue template.', |
||||||
|
}); |
||||||
|
|
||||||
|
await github.rest.issues.update({ |
||||||
|
owner: context.issue.owner, |
||||||
|
repo: context.issue.repo, |
||||||
|
issue_number: context.issue.number, |
||||||
|
state: 'closed', |
||||||
|
}); |
||||||
Loading…
Reference in new issue