Skip to content

Commit

Permalink
Merge pull request #219 from Staffbase/feat/add_dependabot_automerge_…
Browse files Browse the repository at this point in the history
…rebase

Feat: Add strategy selection to dependabot automerge workflow
  • Loading branch information
wmentzel authored Mar 11, 2024
2 parents 160cce3 + 9ffaa3d commit 7d92ae2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
27 changes: 24 additions & 3 deletions .github/workflows/template_automerge_dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ on:
default: false
required: false
type: boolean
strategy:
default: "squash"
required: false
type: string
secrets:
app_id:
required: true
Expand Down Expand Up @@ -44,11 +48,28 @@ jobs:
run: |
gh pr review --approve "$PR_URL"
if [ ${{ inputs.force }} == 'true' ]; then
gh pr merge "$PR_URL" --squash --admin
MERGE_OPTIONS=()
case "${{ inputs.strategy }}" in
"rebase")
MERGE_OPTIONS+=("--rebase")
;;
"merge")
MERGE_OPTIONS+=("--merge")
;;
*)
MERGE_OPTIONS+=("--squash")
;;
esac
if [ "${{ inputs.force }}" == 'true' ]; then
MERGE_OPTIONS+=("--admin")
else
gh pr merge --auto --merge "$PR_URL"
MERGE_OPTIONS+=("--auto")
fi
echo "Executing merge command with the options: '${MERGE_OPTIONS[*]}'"
gh pr merge "$PR_URL" "${MERGE_OPTIONS[@]}"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GITHUB_TOKEN: ${{ steps.get_token.outputs.token }}
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ jobs:
with:
# optional: ⚠️ only enable the force merge if you want to do the merge just now
force: true
# optional: choose strategy when merging (default: squash)
strategy: rebase, merge
secrets:
# identifier of the GitHub App for authentication
app_id: ${{ <your-app-id> }}
Expand Down

0 comments on commit 7d92ae2

Please sign in to comment.