Unverified Commit f0c7e72c authored by Jan Kaifer's avatar Jan Kaifer Committed by GitHub

Create new action that will auto-label issues that have some activity after we…

Create new action that will auto-label issues that have some activity after we mark them as "verify-canary" or "add repro"" (#44815)
parent 98df70e2
This diff is collapsed.
This diff is collapsed.
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()
!package-lock.json
lib/
\ No newline at end of file
name: 'Issue auto label'
description: 'vercel/next.js specific auto-labeling action'
author: 'Next.js team'
runs:
using: 'node16'
main: 'index.js'
This diff is collapsed.
{
"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"
}
{
"compilerOptions": {
"target": "esnext",
"module": "commonjs",
"outDir": "./lib",
"rootDir": "./src",
"strict": true,
"noImplicitAny": true,
"esModuleInterop": true,
"typeRoots": ["./node_modules/@types"]
},
"exclude": ["node_modules", "../../../node_modules"]
}
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 }}
name: Label issues - custom name: On issue label
on: on:
issues: issues:
types: [labeled] types: [labeled]
jobs: jobs:
auto-label: issue-on-label:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: ./.github/actions/issue-auto-label - uses: ./.github/actions/issue-on-label
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment