Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add job to check PR label requirements #1189

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Check labels

on:
pull_request:
branches:
- '*' # Trigger on all branches for pull requests
Copy link
Member

Choose a reason for hiding this comment

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

Should this be master?
I guess in practice it does not make a difference.

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed it to master

types: [opened, synchronize, reopened, labeled, unlabeled]

jobs:
require-challenge:
runs-on: ubuntu-latest
steps:
- uses: mheap/github-action-required-labels@5847eef68201219cf0a4643ea7be61e77837bbce # v5.4.1
with:
mode: exactly
count: 1
labels: "challenged"
add_comment: true
Copy link
Member

Choose a reason for hiding this comment

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

The GitHub Actions token won't have write access if the PR is from a fork, do you know if the action handles that gracefully?

Copy link
Member Author

Choose a reason for hiding this comment

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

I added a permissions section now but it looks as if the workflow still doesn't have the necessary permissions to add a comment to the PR. Looks like the same problem that you had here. Any suggestions welcome.

Copy link
Member

@stempler stempler May 28, 2024

Choose a reason for hiding this comment

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

It's just like that. PR from forks don't get write permissions. You can configure it to allow it, but only for private repos. For public repositories there would only be the way to pass in a separate token that has the required permission (but here you have the same problem because fork PRs don't have access to secrets). So it might be easiest to just not create a comment (if the action does not handle it gracefully).

The error you see right now on this PR though probably stems from trying to add a new workflow from a fork PR, which is also not allowed (I think it would usually run the version it finds in the base branch, but that does not exist). So to properly run on this PR, you would need to create the PR from a fork.

message: "This PR cannot be merged yet because a required label is missing: `{{ provided }}`. It needs to be added before this PR can be merged."
Loading