-
-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
workflows: publish approved PRs upon CI completion #128544
Conversation
7b1ba90
to
8552b35
Compare
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've tested modified versions of these workflows in a separate repository, and it seems like it should work, barring issues with concurrency
and GITHUB_TOKEN
permissions.
There's also the question of all the boilerplate.
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.
Think I'm fine with this but not sure I totally understand
- what it's doing
- why it's needed
- how it differs from the existing auto-merge logic in PRs
- how it differs from/complements/replaces the existing "brewtestbot pushes to PR" flow(s)
Happy to answer these questions post-merge but would love to understand better. Thanks again @carlocab!
This might help refresh your memory: https://machomebrew.slack.com/archives/C06G173B7/p1680113506757109 The idea is that we want a workflow triggered by The solution to that is described in the docs for
So at minimum, what we need is for a The difference with the existing This is mostly independent of the "brewtestbot pushes to PR" flow, I think. We could do this even if we didn't push to PRs, and it doesn't really improve upon or detract from that flow in any way (AFAICT). |
Perfect, all good to me to merge then, thanks @carlocab! |
I'm thinking if this will result in duplicate bottle publish workflow runs if an approval happens to be on the hour (i.e., coincides with the hourly workflow). Maybe we could add a |
@ZhongRuoyu Good point.
They should probably share the same concurrency key. |
Yes, this is one of the |
This is based on one of @MikeMcQuaid's suggestions on Slack. We add an `automerge.yml` workflow that is triggered by the `workflow_run` event. We need this in order to escalate access of `GITHUB_TOKEN` from the `pull_request` and `pull_request_review` events, which can only have read access to the GitHub API. The `automerge` workflow is triggered by two events: - completion of a `CI` workflow on a pull request - approval of a pull request Because both of these events are required in order to merge, we allow the workflow to wait for a while to check if the other event occurs. The basic idea of this workflow was borrowed from the documentation on `workflow_run` events [1]. [1] https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_run
7b49267
to
f1949c5
Compare
This will make sure we only run one of these at a time for any given PR. While we're here: - add stricter checks to make sure we don't attempt to `pr-pull` PRs that we don't want or need to - avoid looping over arrays twice when we don't need to - improve readability by relying less on workflow expression interpolation - use `GITHUB_TOKEN` more often
These are no longer needed.
f1949c5
to
7fdb1e8
Compare
Pushed my branch to this repo for better testing. #128697 |
This is based on one of @MikeMcQuaid's suggestions on Slack.
We add an
automerge.yml
workflow that is triggered by theworkflow_run
event. We need this in order to escalate access ofGITHUB_TOKEN
from thepull_request
andpull_request_review
events,which can only have read access to the GitHub API.
The
automerge
workflow is triggered by two events:CI
workflow on a pull requestBecause both of these events are required in order to merge, we allow
the workflow to wait for a while to check if the other event occurs.
The basic idea of this workflow was borrowed from the documentation on
workflow_run
events.