Repository navigation
Add a require label workflow - #90
paulinevos wants to merge 1 commit into
Conversation
| jobs: | ||
| check: | ||
| name: "Pull request has a label" | ||
| uses: "doctrine/.github/.github/workflows/require-label.yml@use_a_valid_ref_here" |
There was a problem hiding this comment.
Maybe pin to this commit SHA instead of "use_a_valid_ref_here" lol
707f9dd to
4213116
Compare
4213116 to
ff052b0
Compare
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
5 open issues
The workflow is calling a reusable workflow at the same path/name as this file… · New The PR description says the check runs onopened,labeled, andunlabeled, but the workflow… · New This comment states the check blocks merges and should be made a required status check, but the PR… · New In a reusable workflow triggered viaworkflow_call,github.event_nameisworkflow_call, not… · New Using the Pulls API endpoint returns a relatively large payload; for just labels, the Issues… · New
What changed in this PR
Adds a GitHub Actions workflow intended to fail when a pull request has no labels, via a reusable workflow and a local caller workflow.
Changes:
- Added a workflow template YAML + properties card for a “Require label” workflow.
- Added a repository workflow intended to run on PR label and review events and call a reusable workflow.
- Implemented label-check logic using
gh apiand failing with an::error::annotation when label count is zero.
| File | Description |
|---|---|
| workflow-templates/require-label.yml | Adds the label-check job logic intended for reuse/template distribution. |
| workflow-templates/require-label.properties.json | Adds the workflow template metadata card for GitHub’s workflow template picker. |
| .github/workflows/require-label.yml | Adds a workflow that triggers on PR events and calls a reusable workflow by uses:. |
Review effort: Lite
ff052b0 to
60d9c31
Compare
| name: "Pul 8000 l request has a label" | ||
| runs-on: "ubuntu-latest" | ||
| # Every review fires pull_request_review; only approvals re-run the check. | ||
| if: "github.event_name != 'pull_request_review' || github.event.review.state == 'approved'" |
There was a problem hiding this comment.
I don't think I understand the comment and the condition. Didn't we say that it would be useful to have it as soon as a review was posted (even if there wasn't an approval)?
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
3 open issues
5 resolved since last review
The workflow is calling a reusable workflow at the same path/name as this file… In a reusable workflow triggered viaworkflow_call,github.event_nameisworkflow_call, not… This comment states the check blocks merges and should be made a required status check, but the PR… The PR description says the check runs onopened,labeled, andunlabeled, but the workflow… Using the Pulls API endpoint returns a relatively large payload; for just labels, the Issues…
Review effort: Lite
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| run: | | ||
| label_count="$(gh api "repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}" --jq '.labels | length')" |
| name: "Require label" | ||
|
|
||
| on: | ||
| workflow_call: |
| run: | | ||
| label_count="$(gh api "repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}" --jq '.labels | length')" | ||
| if [ "${label_count}" -eq 0 ]; then | ||
| echo "::error::No label is applied to this pull request. Add a label so it can be triaged." | ||
| exit 1 | ||
| fi |



Summary
Adds a reusable workflow that fails when no label is applied to a pull request.
workflow-templates/require-label.ymlqueries the pull request via the API and fails with an::error::annotation when it carries no labels. It needs onlypull-requests: readand never checks out the pull request head.workflow-templates/require-label.properties.jsonis the template card, matching the existing templates.This repository is the template source: the workflow is meant to run in the repositories consuming it, so no caller lives here. A consumer calls it with triggers
pull_request(labeled,unlabeled) andpull_request_review(submitted); inside the reusable workflow a job-level condition skips every review that is not an approval. It deliberately does not run when a pull request opens, so an unlabelled pull request is only flagged once someone approves it. Adding a label re-runs the check and flips an earlier failure back to green.The check blocks merges: consumers should mark it as a required status check so a pull request without a label cannot be merged. It does not block other actions: it is standalone, so no other job or workflow may depend on it.