-
Notifications
You must be signed in to change notification settings - Fork 26.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create new action that will auto-label issues that have some activity…
… after we mark them as "verify-canary" or "add repro"" (#44815)
- Loading branch information
Showing
18 changed files
with
10,462 additions
and
3 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
Large diffs are not rendered by default.
Oops, something went wrong.
File renamed without changes.
Large diffs are not rendered by default.
Oops, something went wrong.
File renamed without changes.
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,45 @@ | ||
import * as github from '@actions/github' | ||
import * as core from '@actions/core' | ||
|
||
const LABELS = { | ||
VERIFY_CANARY: 'please verify canary', | ||
ADD_REPRODUCTION: 'please add a complete reproduction', | ||
NEEDS_TRIAGE: 'type: needs triage', | ||
} | ||
|
||
const labelsRequireUserInput = [LABELS.VERIFY_CANARY, LABELS.ADD_REPRODUCTION] | ||
|
||
function assertNotNullable<T>(value: T): asserts value is NonNullable<T> { | ||
if (value === undefined || value === null) | ||
throw new Error('Unexpected nullable value') | ||
} | ||
|
||
async function run() { | ||
try { | ||
const { payload, repo } = github.context | ||
const { issue, comment } = payload | ||
|
||
assertNotNullable(issue) | ||
assertNotNullable(comment) | ||
|
||
if (!process.env.GITHUB_TOKEN) return | ||
|
||
const client = github.getOctokit(process.env.GITHUB_TOKEN).rest | ||
const issueCommon = { ...repo, issue_number: issue.number } | ||
|
||
const issueLabels: string[] = issue.labels.map((label: any) => label.name) | ||
|
||
if (labelsRequireUserInput.some((label) => issueLabels.includes(label))) { | ||
if (comment.user.type !== 'Bot') { | ||
client.issues.addLabels({ | ||
...issueCommon, | ||
labels: [LABELS.NEEDS_TRIAGE], | ||
}) | ||
} | ||
} | ||
} catch (error: any) { | ||
core.setFailed(error.message) | ||
} | ||
} | ||
|
||
run() |
File renamed without changes.
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,2 @@ | ||
!package-lock.json | ||
lib/ |
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,6 @@ | ||
name: 'Issue auto label' | ||
description: 'vercel/next.js specific auto-labeling action' | ||
author: 'Next.js team' | ||
runs: | ||
using: 'node16' | ||
main: 'index.js' |
File renamed without changes.
Large diffs are not rendered by default.
Oops, something went wrong.
File renamed without changes.
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,22 @@ | ||
{ | ||
"private": true, | ||
"exports": "./index.js", | ||
"files": [ | ||
"src" | ||
], | ||
"scripts": { | ||
"types": "tsc", | ||
"pack": "ncc -m -o . build lib/index.js --license licenses.txt", | ||
"build": "npm run types && npm run pack" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^18.11.0", | ||
"@vercel/ncc": "0.34.0", | ||
"typescript": "^4.4.4" | ||
}, | ||
"dependencies": { | ||
"@actions/core": "1.10.0", | ||
"@actions/github": "5.1.1" | ||
}, | ||
"packageManager": "npm@9.2.0" | ||
} |
File renamed without changes.
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,13 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "esnext", | ||
"module": "commonjs", | ||
"outDir": "./lib", | ||
"rootDir": "./src", | ||
"strict": true, | ||
"noImplicitAny": true, | ||
"esModuleInterop": true, | ||
"typeRoots": ["./node_modules/@types"] | ||
}, | ||
"exclude": ["node_modules", "../../../node_modules"] | ||
} |
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,14 @@ | ||
name: On issue comment | ||
|
||
on: | ||
issue_comment: | ||
types: [created] | ||
|
||
jobs: | ||
issue-on-comment: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: ./.github/actions/issue-on-comment | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
6 changes: 3 additions & 3 deletions
6
.github/workflows/issue_auto_label.yml → .github/workflows/issue_on_label.yml
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 |
---|---|---|
@@ -1,14 +1,14 @@ | ||
name: Label issues - custom | ||
name: On issue label | ||
|
||
on: | ||
issues: | ||
types: [labeled] | ||
|
||
jobs: | ||
auto-label: | ||
issue-on-label: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: ./.github/actions/issue-auto-label | ||
- uses: ./.github/actions/issue-on-label | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |