forked from vercel/next.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(github): add issue_wrong_template workflow (vercel#73882)
## Why? Mini-automation to automatically close issues when using the `please use the correct issue template` label.
- Loading branch information
Showing
6 changed files
with
979 additions
and
728 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
.github/actions/next-repo-actions/dist/wrong-issue-template/index.js
Large diffs are not rendered by default.
Oops, something went wrong.
612 changes: 612 additions & 0 deletions
612
.github/actions/next-repo-actions/dist/wrong-issue-template/licenses.txt
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
.github/actions/next-repo-actions/src/wrong-issue-template.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
Oops, something went wrong.