Skip to content

Commit

Permalink
chore(github): add issue_wrong_template workflow (vercel#73882)
Browse files Browse the repository at this point in the history
## Why?

Mini-automation to automatically close issues when using the `please use the correct issue template` label.
  • Loading branch information
samcx authored Dec 13, 2024
1 parent 08bb9fc commit 8e64b2c
Show file tree
Hide file tree
Showing 6 changed files with 979 additions and 728 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions .github/actions/next-repo-actions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
"private": true,
"description": "Notify Next.js team about pending PRs and popular issues",
"scripts": {
"build": "pnpm build-issues-by-version && pnpm build-issues && pnpm build-prs && pnpm build-feature-requests && pnpm build-bankrupt-issues && pnpm build-triage-issues-with-ai",
"build-issues-by-version": "ncc build src/issues-by-version.ts -m -o dist/issues-by-version --license licenses.txt",
"build-issues": "ncc build src/popular-issues.mjs -m -o dist/issues --license licenses.txt",
"build-prs": "ncc build src/popular-prs.ts -m -o dist/prs --license licenses.txt",
"build-feature-requests": "ncc build src/popular-feature-requests.mjs -m -o dist/feature-requests --license licenses.txt",
"build-bankrupt-issues": "ncc build src/bankrupt-issues.ts -m -o dist/bankrupt --license licenses.txt",
"build-triage-issues-with-ai": "ncc build src/triage-issues-with-ai.ts -m -o dist/triage-issues-with-ai --license licenses.txt"
"build-triage-issues-with-ai": "ncc build src/triage-issues-with-ai.ts -m -o dist/triage-issues-with-ai --license licenses.txt",
"build-wrong-issue-template": "ncc build src/wrong-issue-template.ts -m -o dist/wrong-issue-template --license licenses.txt"
},
"dependencies": {
"@actions/core": "^1.11.1",
Expand All @@ -21,6 +21,6 @@
"zod": "^3.23.8"
},
"devDependencies": {
"@vercel/ncc": "^0.38.2"
"@vercel/ncc": "^0.38.3"
}
}
38 changes: 38 additions & 0 deletions .github/actions/next-repo-actions/src/wrong-issue-template.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { info, setFailed } from '@actions/core'
import { context, getOctokit } from '@actions/github'

async function main() {
if (!process.env.GITHUB_TOKEN) throw new TypeError('GITHUB_TOKEN not set')

const octokit = getOctokit(process.env.GITHUB_TOKEN)

const { owner, repo } = context.repo
const issue = context.payload.issue
const body = `
This issue has been closed due to the incorrect issue template being used. Please make sure to submit a new issue using the [correct issue template](https://github.com/vercel/next.js/issues/new?assignees=&labels=bug&projects=&template=1.bug_report.yml). This will ensure that we have all the necessary information to triage your issue. Thank you.
`

try {
await octokit.rest.issues.createComment({
owner,
repo,
issue_number: issue.number,
body,
})

await octokit.rest.issues.update({
owner,
repo,
issue_number: issue.number,
state: 'closed',
})

info(
`Issue #${issue.number}, which was opened with the incorrect template, has been successfully closed.`
)
} catch (error) {
setFailed(error)
}
}

main()
Loading

0 comments on commit 8e64b2c

Please sign in to comment.