Conversation
Adds .github/workflows/auto-label-triage.yml to auto-label new PRs with 'triage' via actions/github-script@v7. Prepends 'triage' to the require-labels allowed list so the label gate passes deterministically on PR open. Prevents the blocker seen on PR #12 where a PR with no labels stalled the required-labels check.
|
|
There was a problem hiding this comment.
Pull request overview
Formålet med PR-en er å redusere friksjon ved opprettelse av PR-er ved automatisk å legge på en triage-label slik at require-labels-sjekken ikke blokkerer før et menneske rekker å merke PR-en.
Changes:
- Ny workflow som forsøker å auto-labele nye PR-er med
triageved åpning. - Oppdatert
require-labelstil å aksepteretriagesom gyldig label.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
.github/workflows/auto-label-triage.yml |
Legger til workflow som auto-appliserer triage-label på PR open. |
.github/workflows/require-labels.yml |
Oppdaterer whitelist for labels slik at triage-label kan tilfredsstille label-gate. |
| await github.rest.issues.addLabels({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: context.payload.pull_request.number, | ||
| labels: ['triage'] | ||
| }); |
There was a problem hiding this comment.
Workflow uses the label name triage, but this repo’s label taxonomy file defines status:triage (see labels.yml:64-66). If label sync is used, triage may not exist and the API call will fail. Consider switching to status:triage (and keeping naming consistent with other status:* labels).
| permissions: | ||
| pull-requests: write | ||
| issues: write | ||
|
|
There was a problem hiding this comment.
pull-requests: write doesn’t appear to be needed here: the script calls github.rest.issues.addLabels, which only requires issues: write. To follow least-privilege, drop the extra scope (or scope permissions at the job level).
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Add triage label to new PR | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| await github.rest.issues.addLabels({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: context.payload.pull_request.number, | ||
| labels: ['triage'] | ||
| }); |
There was a problem hiding this comment.
On PRs from forks, the GITHUB_TOKEN for pull_request events is typically read-only, so issues.addLabels can fail with 403 and make the workflow red. Add an explicit guard (e.g., skip when github.event.pull_request.head.repo.fork is true) and/or handle 403 as a non-fatal outcome to avoid noisy failures.
| mode: minimum | ||
| count: 1 | ||
| labels: "bug, enhancement, documentation, dependencies, ci-cd, security, configuration, testing, wontfix, duplicate, invalid, question" | ||
| labels: "triage, bug, enhancement, documentation, dependencies, ci-cd, security, configuration, testing, wontfix, duplicate, invalid, question" |
There was a problem hiding this comment.
triage was added to the allowed-label list, but the repo’s label taxonomy defines status:triage (see labels.yml:64-66). If the intent is to use the standardized label set, rename this entry to status:triage (and keep auto-label-triage.yml consistent) to avoid the required-labels check accepting a label that may not exist.
Summary
.github/workflows/auto-label-triage.yml— onpull_request: opened, applies thetriagelabel viaactions/github-script@v7. Permissions scoped topull-requests: write+issues: write.triageto the allowed labels list in.github/workflows/require-labels.ymlso auto-appliedtriagesatisfies the gate.triagelabel provisioned in the repo (colorfbca04, "Needs triage").Prevents the blocker seen on #12, where a PR opened without labels stalled the
require-labelscheck until a human intervened. New PRs now pass the gate on open; authors can still refine labels afterwards.Verification
actionlint(rhysd/actionlint Docker container): clean on both workflows.yamllint: only pre-existingdocument-startandline-lengthwarnings, consistent with repo convention; no new errors.security+ci-cdlabels added,require-labelscheck now passing.Test plan
actionlintpasses on the new workflowyamllintclean (no new violations)require-labels(labelsci-cd,enhancementapplied)triageautomatically