diff --git a/.github/workflows/template_automerge_dependabot.yml b/.github/workflows/template_automerge_dependabot.yml index 53cfd67..42be77a 100644 --- a/.github/workflows/template_automerge_dependabot.yml +++ b/.github/workflows/template_automerge_dependabot.yml @@ -8,6 +8,10 @@ on: default: false required: false type: boolean + strategy: + default: "squash" + required: false + type: string secrets: app_id: required: true @@ -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 }} diff --git a/README.md b/README.md index 2f91b66..cbaaea3 100644 --- a/README.md +++ b/README.md @@ -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: ${{ }}