Skip to content

Commit 45b6e69

Browse files
authored
Add auto approval for auto merge (#68)
The auto merge process needs two reviews to meet Project Mu branch protection policy requirements. This change auto approves dependency update pull requests so they can be auto merged. Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
1 parent f6e211d commit 45b6e69

2 files changed

Lines changed: 30 additions & 2 deletions

File tree

.github/workflows/AutoMerger.yml

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,27 @@ on:
1313
workflow_call:
1414

1515
jobs:
16+
bot_approval:
17+
name: Bot Approval
18+
if: |
19+
github.event_name == 'pull_request_target' &&
20+
(github.event.action == 'opened' || github.event.action == 'reopened') &&
21+
(github.event.pull_request.user.login == 'dependabot[bot]' || github.event.pull_request.user.login == 'uefibot')
22+
runs-on: ubuntu-latest
23+
permissions:
24+
pull-requests: write
25+
26+
steps:
27+
- uses: hmarr/auto-approve-action@v3
28+
with:
29+
github-token: ${{ secrets.GITHUB_TOKEN }}
30+
review-message: "🤖 auto approved a ${{ github.event.pull_request.user.login }} PR."
31+
32+
- uses: hmarr/auto-approve-action@v3
33+
with:
34+
github-token: ${{ secrets.PROJECT_MU_BOT_TOKEN }}
35+
review-message: "🤖 auto approved a ${{ github.event.pull_request.user.login }} PR."
36+
1637
auto_merge:
1738
name: Merge
1839
runs-on: ubuntu-latest
@@ -28,13 +49,14 @@ jobs:
2849
id: auto_merge
2950
uses: pascalgn/automerge-action@v0.15.5
3051
env:
31-
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
52+
GITHUB_TOKEN: "${{ secrets.PROJECT_MU_BOT_TOKEN }}"
53+
MERGE_ERROR_FAIL: "false" # Do not fail if an auto merge couldn't happen
3254
MERGE_FILTER_AUTHOR: "${{ matrix.author }}"
3355
MERGE_FORKS: "false" # dependabot and uefibot come from local repo branches - forks not needed
3456
MERGE_LABELS: "!state:duplicate,!state:invalid,!state:needs-maintainer-feedback,!state:needs-submitter-info,!state:under-discussion,!state:wont-fix,!type:notes,!type:question"
3557
MERGE_METHOD: "squash" # Default merge method squash (instead of "merge")
3658
MERGE_REMOVE_LABELS: = "" # Do not remove any labels from a PR after merge
37-
MERGE_REQUIRED_APPROVALS: "0" # Auto merge these PRs without human reviewers involved (need to pass PR gates)
59+
MERGE_REQUIRED_APPROVALS: "2" # Two PRs can be humans or bots (need to pass PR gates)
3860
MERGE_RETRIES: "6" # Check if PR status checks pass up to 6 times
3961
MERGE_RETRY_SLEEP: "10000" # Check if PR status checks are met every 10 secs (6 * 10 = check over 1 min)
4062
UPDATE_LABELS: "" # Always update these PRs if needed to merge

.sync/workflows/leaf/auto-merge.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,10 @@ on:
3838

3939
jobs:
4040
merge_check:
41+
if: |
42+
((github.event_name == 'pull_request_target' || github.event_name == 'pull_request_review') &&
43+
(github.event.pull_request.user.login == 'dependabot[bot]' || github.event.pull_request.user.login == 'uefibot')) ||
44+
((github.event_name == 'check_suite') &&
45+
(github.event.check_suite.sender.login == 'dependabot[bot]' || github.event.check_suite.sender.login == 'uefibot'))
4146
uses: microsoft/mu_devops/.github/workflows/AutoMerger.yml@{{ sync_version.mu_devops }}
47+
secrets: inherit

0 commit comments

Comments
 (0)