Skip to content

Create Label

Create Label #462

Workflow file for this run

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);
}
}