8000 Add a require label workflow by paulinevos · Pull Request #90 · doctrine/.github · GitHub
[go: up one dir, main page]

Skip to content

Add a require label workflow - #90

Open
paulinevos wants to merge 1 commit into
doctrine:mainfrom
paulinevos:require-label-workflow
Open

paulinevos wants to merge 1 commit into
doctrine:mainfrom
paulinevos:require-label-workflow

Conversation

@paulinevos
@paulinevos paulinevos commented Nov 5, 2026 •
Copy link
Copy Markdown
Member

Summary

Adds a reusable workflow that fails when no label is applied to a pull request.

  • workflow-templates/require-label.yml queries the pull request via the API and fails with an ::error:: annotation when it carries no labels. It needs only pull-requests: read and never checks out the pull request head.
  • workflow-templates/require-label.properties.json is 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) and pull_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.

Copilot AI balanced review requested due to automatic review settings November 5, 2026 13:22
Comment thread .github/workflows/require-label.yml Resolved
Comment thread .github/workflows/require-label.yml Outdated
jobs:
check:
name: "Pull request has a label"
uses: "doctrine/.github/.github/workflows/require-label.yml@use_a_valid_ref_here"
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe pin to this commit SHA instead of "use_a_valid_ref_here" lol

@paulinevos
paulinevos force-pushed the require-label-workflow branch from 707f9dd to 4213116 Compare November 5, 2026 13:30
Comment thread .github/workflows/require-label.yml Resolved
@paulinevos
paulinevos force-pushed the require-label-workflow branch from 4213116 to ff052b0 Compare November 5, 2026 13:34
@paulinevos
paulinevos marked this pull request as ready for review November 5, 2026 13:36
Copilot AI left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
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 api and 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

Comment thread .github/workflows/require-label.yml Resolved
Comment threa 8000 d .github/workflows/require-label.yml Resolved
Comment thread .github/workflows/require-label.yml Resolved
Comment thread workflow-templates/require-label.yml Resolved
Comment thread workflow-templates/require-label.yml Resolved
@paulinevos
paulinevos force-pushed the require-label-workflow branch from ff052b0 to 60d9c31 Compare November 5, 2026 15:06
@paulinevos
paulinevos requested review from greg0ire and a balanced review from Copilot November 5, 2026 15:09
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'"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)?

Copilot AI left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:
Comment on lines +20 to +25
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

0