Skip to content

Conversation

@Reettaphant
Copy link
Contributor

Workflow to require one of the core4 labels on pull requests before merging. It contains an extra don't know label at the moment, this was a request so that we can see which pull requests people have trouble labelling. We will remove this label in the future when it is no longer needed.

@Reettaphant Reettaphant requested a review from a team as a code owner November 14, 2025 15:09
Co-authored-by: TJ Silver <15648334+tjsilver@users.noreply.github.com>
@tjsilver tjsilver force-pushed the rv-require-core4-labels branch from 7a5ff92 to d10b44a Compare November 18, 2025 10:47
@tjsilver tjsilver force-pushed the rv-require-core4-labels branch from d10b44a to ad4fbb6 Compare November 18, 2025 10:51
Copy link
Contributor

@adamnfish-gu adamnfish-gu left a comment

Choose a reason for hiding this comment

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

Be good to chat about how this will get rolled out to each (production?) repository, but I'm sure you've already considered this!

The trouble with the approach is that I imagine people are going to open a PR and then add the labels to that PR, which means this will always need manually re-running, because it triggers on the PR being opened.

We can add additional types to the PR trigger to improve the UX:

on:
  pull_request:
    types:
      - labeled
      - unlabeled
      - ... others

I also think we can simplify the implementation a bit, as a I mention in another comment. Here's an example of the changes I talked about on a different branch, in case that's helpful?

https://github.com/guardian/.github/compare/require-core4-labels-alternative

@adamnfish-gu adamnfish-gu added feature Departmental tracking: work on a new feature and removed feature Departmental tracking: work on a new feature labels Nov 19, 2025
@tjsilver
Copy link
Contributor

Be good to chat about how this will get rolled out to each (production?) repository, but I'm sure you've already considered this!

The trouble with the approach is that I imagine people are going to open a PR and then add the labels to that PR, which means this will always need manually re-running, because it triggers on the PR being opened.

We can add additional types to the PR trigger to improve the UX:

on:
  pull_request:
    types:
      - labeled
      - unlabeled
      - ... others

I also think we can simplify the implementation a bit, as a I mention in another comment. Here's an example of the changes I talked about on a different branch, in case that's helpful?

https://github.com/guardian/.github/compare/require-core4-labels-alternative

Unfortunately because this is a centralised workflow, the usual triggers will not work, such as labeled, unlabeled, etc, as they take their context from the repo that the workflow is in, rather than the repo it is running in. That is why we had to come up with this solution here.

LABELS: ${{ toJSON(github.event.pull_request.labels.*.name)}}
with:
script: |
const labels = JSON.parse(process.env.LABELS);
Copy link
Contributor

Choose a reason for hiding this comment

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

I tested this on test-repocop-prs and the workflow failed on the creation of a PR without a label (as expected) and then re-ran automatically after I added a label.

Copy link
Contributor

@tjsilver tjsilver left a comment

Choose a reason for hiding this comment

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

If we are happy with the idea that this workflow will always fail on the first run when a user opens a PR (inevitably they will open it before before labelling), then it's good to go.

@Reettaphant Reettaphant merged commit ea51e21 into main Nov 27, 2025
2 checks passed
@Reettaphant Reettaphant deleted the rv-require-core4-labels branch November 27, 2025 15:11
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.

4 participants