adding Ura labels via GHA workflow - do not merge #1
Workflow file for this run
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: Update repository labels | |
on: | |
push: | |
branches: | |
- label-add-nomerge | |
paths: | |
- '.github/workflows/labels.yml' | |
jobs: | |
create-labels: | |
runs-on: ubuntu-latest | |
permissions: | |
issues: write | |
env: | |
LABELS_JSON: | | |
[ | |
{"name": "A11y review needed", "color": "eded8d", "description": ""}, | |
{"name": "A11y review +1", "color": "8ded8d", "description": ""}, | |
{"name": "A11y review -1", "color": "ed8d8d", "description": ""}, | |
{"name": "QA review needed", "color": "eded8d", "description": ""}, | |
{"name": "QA review +1", "color": "8ded8d", "description": ""}, | |
{"name": "QA review -1", "color": "ed8d8d", "description": ""}, | |
{"name": "UX review needed", "color": "eded8d", "description": ""}, | |
{"name": "UX review +1", "color": "8ded8d", "description": ""}, | |
{"name": "UX review -1", "color": "ed8d8d", "description": ""}, | |
{"name": "Visual Design review needed", "color": "eded8d", "description": ""}, | |
{"name": "Visual Design review +1", "color": "8ded8d", "description": ""}, | |
{"name": "Visual Design review -1", "color": "ed8d8d", "description": ""} | |
] | |
steps: | |
- uses: actions/github-script@v7 | |
with: | |
script: | | |
const labels = JSON.parse(process.env.LABELS_JSON); | |
for (const label of labels) { | |
try { | |
await github.rest.issues.createLabel({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
name: label.name, | |
description: label.description || '', | |
color: label.color | |
}); | |
} catch (error) { | |
// Check if the error is because the label already exists | |
if (error.status === 422) { | |
console.log(`Label '${label.name}' already exists. Skipping.`); | |
} else { | |
// Log other errors | |
console.error(`Error creating label '${label.name}': ${error}`); | |
} | |
} | |
} |