Create Label #462
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
name: Create Label | |
on: | |
workflow_dispatch: | |
inputs: | |
project_name: | |
description: 'The project name to use for the label' | |
required: true | |
default: 'default' | |
type: string | |
jobs: | |
create-label: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Create label | |
uses: actions/github-script@v7 | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
script: | | |
const { project_name } = context.payload.inputs | |
const { repo: { owner, repo } } = context; | |
const name = `team: ${project_name}`; | |
const color = 'f1c40f'; | |
const description = `A PR belonging to the ${project_name} project.`; | |
try { | |
await github.rest.issues.createLabel({ | |
owner, | |
repo, | |
name, | |
color, | |
description, | |
}); | |
console.log(`Label "${name}" created.`); | |
} catch (error) { | |
if (error.status === 422) { | |
console.log(`Label "${name}" already exists.`); | |
} else { | |
console.error(error); | |
} | |
} |