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

build: fix auto merge with merge queues #1213

Merged
merged 2 commits into from
Jul 24, 2024
Merged
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
30 changes: 23 additions & 7 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
name: Build and test
on:
pull_request: { }
push:
branches:
- 'staging'
- main
- stable/*
- release-*
pull_request: { }
merge_group: { }
workflow_call: { }

concurrency:
Copy link
Member Author

Choose a reason for hiding this comment

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

💭 Added this as a nice to have copied from the Zeebe CI. I can remove it of course, but it's generally useful to avoid having multiple runs for the same commit.

cancel-in-progress: true
group: "${{ github.workflow }}-${{ github.ref }}"

defaults:
run:
# use bash shell by default to ensure pipefail behavior is the default
# see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference
shell: bash

jobs:
code-formatting:
name: check code formatting
Expand Down Expand Up @@ -160,7 +174,7 @@ jobs:
# Once we're using the merge queue feature, I think we can simplify this workflow a lot by relying
# on dependabot merging PRs via its commands, as it will always wait for checks to be green before
# merging.
name: Auto-merge dependabot and camundait PRs
name: Auto-merge dependabot, camundait, and backport PRs
runs-on: ubuntu-latest
needs: [ test-summary ]
if: github.repository == 'camunda/zeebe-process-test' && (github.actor == 'dependabot[bot]' || github.actor == 'camundait' || github.actor == 'backport-action')
Expand All @@ -178,13 +192,15 @@ jobs:
- id: approve-and-merge-dependabot
name: Approve and merge dependabot PR
if: github.actor == 'dependabot[bot]' && (steps.metadata.outputs.update-type == 'version-update:semver-patch' || steps.metadata.outputs.update-type == 'version-update:semver-minor')
run: gh pr review ${{ github.event.pull_request.number }} --approve -b "bors merge"
run: gh pr merge --auto --merge "$PR_URL"
Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

❌ This won't work:

This enables the pull request to be merged when any tests and approvals required by the branch protection rules are successfully met

You removed the approval, so when you enable auto-merge it will only start the merge once someone gives approval.

env:
GITHUB_TOKEN: "${{secrets.GITHUB_TOKEN}}"
PR_URL: ${{github.event.pull_request.html_url}}
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
- id: approve-and-merge-backport
name: Approve and merge backport PR
if: github.actor != 'dependabot[bot]'
run: gh pr review ${{ github.event.pull_request.number }} --approve -b "bors merge"
run: gh pr merge --auto --merge "$PR_URL"
env:
GITHUB_TOKEN: "${{secrets.GITHUB_TOKEN}}"
PR_URL: ${{github.event.pull_request.html_url}}
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}

Loading