From 4104f8385e3d30baa39311530b0ecb2c8fb24a60 Mon Sep 17 00:00:00 2001 From: Falk Puschner Date: Wed, 15 Nov 2023 11:03:58 +0100 Subject: [PATCH] :art: Force automerge as admin (#199) * :art: Force automerge as admin * :lipstick: Make linter happy * :truck: Rename admin variable to force * :art: Change default type for force * :memo: Add force documentation * :memo: Add hint for prrotection rules * :memo: Only run if the PR is created * :arrow_down: More explanation for force merge --- .github/workflows/template_automerge_dependabot.yml | 12 +++++++++++- README.md | 11 ++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/.github/workflows/template_automerge_dependabot.yml b/.github/workflows/template_automerge_dependabot.yml index e2c1d3e..e3e79f6 100644 --- a/.github/workflows/template_automerge_dependabot.yml +++ b/.github/workflows/template_automerge_dependabot.yml @@ -3,6 +3,11 @@ name: Dependabot Auto-Merge on: workflow_call: + inputs: + force: + default: false + required: false + type: boolean secrets: app_id: required: true @@ -35,7 +40,12 @@ jobs: if: steps.metadata.outputs.update-type == 'version-update:semver-patch' || steps.metadata.outputs.update-type == 'version-update:semver-minor' run: | gh pr review --approve "$PR_URL" - gh pr merge --auto --merge "$PR_URL" + + if [ ${{ inputs.force }} == 'true' ]; then + gh pr merge "$PR_URL" --merge --admin + else + gh pr merge --auto --merge "$PR_URL" + fi env: PR_URL: ${{ github.event.pull_request.html_url }} GITHUB_TOKEN: ${{ steps.get_token.outputs.token }} diff --git a/README.md b/README.md index 77e0a44..1b80538 100644 --- a/README.md +++ b/README.md @@ -29,15 +29,24 @@ In this section you can find examples of how to use template workflows. For more The action can be used to auto-merge a dependabot PR with minor and patch updates. The action is called by creating a PR. It is necessary that the repository is enabled for auto-merge. +Afterward the PR will be merged with the help of the merge queue if all required conditions of the repository are fulfilled. + +⚠️ You can also force a merge of a PR. This means that the PR will immediately be merged. +If you want to enable the force merge, make sure that the app can bypass any protection rules. ```yml name: Enable Dependabot Auto-Merge -on: pull_request +on: + pull_request: + types: [opened] jobs: dependabot: uses: Staffbase/gha-workflows/.github/workflows/template_automerge_dependabot.yml@v3.2.0 + with: + # optional: ⚠️ only enable the force merge if you want to do the merge just now + force: true secrets: # identifier of the GitHub App for authentication app_id: ${{ }}