-
Notifications
You must be signed in to change notification settings - Fork 14k
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
feat(actions): auto-label PRs that close issues. #27047
Conversation
- name: Auto-label PRs | ||
uses: actions/github-script@v7 | ||
with: | ||
github-token: ${{secrets.GITHUB_TOKEN}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't think we have access to secrets
when triggering by pull_request
. it works on PRs that don't come from forks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had read somewhere that the repo does provide a generated GITHUB_TOKEN with limited authority (tagging, commenting, etc) on forks, so this should work.
I can add a secrets check to skip the job if the secret is not available, but I think that secret always is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I kinda want to merge it and test the theory. I can add the secret check to skip the action if it doesn't work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think your right, but default access is readonly: https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token
for PRs from forks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm... and I see the labeller action above the one I'm adding here has
permissions:
contents: read
pull-requests: write
... but I'm (a) not sure if that job works on forks (maybe that's broken too?), or (b) if we can elevate the default permissions like that.
I'm not sure yet if there's a better approach here, or if there's a way to skip this action for forks if we can't make it work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious to know if we are moving forward with this as I am planning to consider it for a long-term proposal to improve the management of the backlog
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I sure WANT to merge it, but I'm not sure how to proceed. Maybe @mistercrunch knows how to unblock this thing :P
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe using pull_request_target
?
https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case, what happens is it will trigger the action that's defined on the main target repo's branch, and say if you do a checkout it would be the target's ref not the PR one. Does that work here? Actually do you need to checkout?
label-auto-closing: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure you need to checkout here?
SUMMARY
Just a theory, but this should look at any given PR and check the description body to see if it auto-closes any issues. If so, label the thing! This should help us prioritize PRs that will also help whittle the Issues backlog.
This also looks at more triggers (including "edited") to run the action on PR description edits. The jobs in the action can be triggered by subsets of these actions (e.g. the main labeler doesn't run on PR description edits).
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
Go ahead! Edit this PR description, and look for the addition/removal of the label!
ADDITIONAL INFORMATION