Skip to content

Commit

Permalink
🎨 Force automerge as admin (#199)
Browse files Browse the repository at this point in the history
* 🎨 Force automerge as admin

* 💄 Make linter happy

* 🚚 Rename admin variable to force

* 🎨 Change default type for force

* 📝 Add force documentation

* 📝 Add hint for prrotection rules

* 📝 Only run if the PR is created

* ⬇️ More explanation for force merge
  • Loading branch information
flaxel authored Nov 15, 2023
1 parent 3a2d596 commit 4104f83
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/template_automerge_dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ name: Dependabot Auto-Merge

on:
workflow_call:
inputs:
force:
default: false
required: false
type: boolean
secrets:
app_id:
required: true
Expand Down Expand Up @@ -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 }}
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,24 @@ In this section you can find examples of how to use template workflows. For more
<summary>The action can be used to auto-merge a dependabot PR with minor and patch updates.</summary>
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/[email protected]
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: ${{ <your-app-id> }}
Expand Down

0 comments on commit 4104f83

Please sign in to comment.