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

Autolabel with linear when labeled with kind: bug (#44774)

Creates a new workflow and action that auto labels with `linear` whenever we apply `kind: bug`.
It's using JS action instead of docker, so it should be quite fast.

I tested this on my fork and it works.

Also created the action with TS so we can use it as a starting point for next actions so they can all be typed.
parent ee0f4831
!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.
This diff is collapsed.
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"
}
import * as github from '@actions/github'
import * as core from '@actions/core'
const LABELS = {
LINEAR: 'linear',
KIND_BUG: 'kind: bug',
}
async function run() {
try {
const { payload, repo } = github.context
const {
issue,
pull_request,
label: { name: newLabel },
} = payload
if (pull_request || !issue?.body || !process.env.GITHUB_TOKEN) return
const client = github.getOctokit(process.env.GITHUB_TOKEN).rest
const issueCommon = { ...repo, issue_number: issue.number }
if (newLabel === LABELS.KIND_BUG) {
client.issues.addLabels({
...issueCommon,
labels: [LABELS.LINEAR],
})
}
} catch (error: any) {
core.setFailed(error.message)
}
}
run()
{
"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: Label issues - custom
on:
issues:
types: [labeled]
jobs:
auto-label:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/issue-auto-label
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# https://github.com/github/issue-labeler#create-workflow
name: Label issues
name: Label issues - GH Labeler
on:
issues:
......
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