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

workflows: publish approved PRs on CI completion #128817

Merged
merged 1 commit into from
Apr 20, 2023
Merged

Conversation

carlocab
Copy link
Member

@carlocab carlocab commented Apr 20, 2023

This is a continuation of #128697 and #128544.

We need to now check the PR's mergeable_state to make sure we're merging something with a green approval (rather than a grey one).

See octokit/octokit.net#1763 for more details on mergeable_state.

@carlocab carlocab requested review from a team and MikeMcQuaid as code owners April 20, 2023 01:16
@github-actions github-actions bot added automerge-skip `brew pr-automerge` will skip this pull request workflows PR modifies GitHub Actions workflow files labels Apr 20, 2023
@carlocab carlocab marked this pull request as draft April 20, 2023 04:41
@carlocab carlocab force-pushed the automerge-on-approval branch from dac92b8 to 055a66f Compare April 20, 2023 05:02
@carlocab carlocab marked this pull request as ready for review April 20, 2023 05:02
@carlocab carlocab force-pushed the automerge-on-approval branch from 055a66f to 1b3f464 Compare April 20, 2023 05:24
.github/workflows/automerge.yml Outdated Show resolved Hide resolved
.github/workflows/automerge.yml Show resolved Hide resolved
@ZhongRuoyu ZhongRuoyu enabled auto-merge April 20, 2023 06:46
@ZhongRuoyu ZhongRuoyu disabled auto-merge April 20, 2023 06:46
@ZhongRuoyu
Copy link
Member

Sorry, didn't intend to click that. (I was using the mobile app.)

@carlocab carlocab force-pushed the automerge-on-approval branch 2 times, most recently from 9abf80b to 4047253 Compare April 20, 2023 08:08
MikeMcQuaid
MikeMcQuaid previously approved these changes Apr 20, 2023
Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

Looking good so far!

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
Copy link
Member

@ZhongRuoyu ZhongRuoyu left a comment

Choose a reason for hiding this comment

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

Thanks for your great work!

@carlocab
Copy link
Member Author

Ok, let's merge this while I have a few hours to watch the queue to make sure nothing 💥

@carlocab carlocab added this pull request to the merge queue Apr 20, 2023
Merged via the queue into master with commit 1d607f6 Apr 20, 2023
@carlocab carlocab deleted the automerge-on-approval branch April 20, 2023 16:09
@carlocab
Copy link
Member Author

For the record, if anything 💥, it's easy enough to disable the automerge workflow without having to do any reverts:

Screenshot 2023-04-21 at 00 11 06

@ZhongRuoyu
Copy link
Member

We're seeing a number of failures, because the (outdated) CI workflow did not produce the pull-number artifact. But that's expected I guess.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge-skip `brew pr-automerge` will skip this pull request workflows PR modifies GitHub Actions workflow files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants