From df849cecf8497151455b702e042f13464a02813a Mon Sep 17 00:00:00 2001 From: Thibaud Bonnefoy Date: Fri, 2 Feb 2024 17:36:35 +0100 Subject: [PATCH 01/14] feat(automerge): add rebase strategy --- .../template_automerge_dependabot.yml | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/.github/workflows/template_automerge_dependabot.yml b/.github/workflows/template_automerge_dependabot.yml index 53cfd67..f1bebf2 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 + rebase: + default: false + required: false + type: boolean secrets: app_id: required: true @@ -44,11 +48,20 @@ jobs: run: | gh pr review --approve "$PR_URL" - if [ ${{ inputs.force }} == 'true' ]; then - gh pr merge "$PR_URL" --squash --admin + MERGE_COMMAND="gh pr merge \"$PR_URL\"" + + if [ "${{ inputs.force }}" == 'true' ] && [ "${{ inputs.rebase }}" == 'true' ]; then + MERGE_COMMAND+=" --rebase --admin" + elif [ "${{ inputs.force }}" == 'true' ]; then + MERGE_COMMAND+=" --squash --admin" + elif [ "${{ inputs.rebase }}" == 'true' ]; then + MERGE_COMMAND+=" --rebase" else - gh pr merge --auto --merge "$PR_URL" + MERGE_COMMAND+=" --auto --merge" fi + + echo "Executing merge command: $MERGE_COMMAND" + eval $MERGE_COMMAND env: PR_URL: ${{ github.event.pull_request.html_url }} GITHUB_TOKEN: ${{ steps.get_token.outputs.token }} From f2ee383d0c1b7b598c23cbe9bee9ccc08ebc3b5b Mon Sep 17 00:00:00 2001 From: Thibaud Bonnefoy Date: Fri, 2 Feb 2024 17:42:02 +0100 Subject: [PATCH 02/14] doc(automerge): update readme with rebase option --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 2f91b66..bca5c27 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: enable rebase strategy when merging (default: false) + rebase: true secrets: # identifier of the GitHub App for authentication app_id: ${{ }} From a9c1b40d6d589f201c71e884172446647e4d60c4 Mon Sep 17 00:00:00 2001 From: Thibaud Bonnefoy Date: Fri, 2 Feb 2024 18:31:24 +0100 Subject: [PATCH 03/14] style: make linter happy again --- .github/workflows/template_automerge_dependabot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/template_automerge_dependabot.yml b/.github/workflows/template_automerge_dependabot.yml index f1bebf2..9df018a 100644 --- a/.github/workflows/template_automerge_dependabot.yml +++ b/.github/workflows/template_automerge_dependabot.yml @@ -59,7 +59,7 @@ jobs: else MERGE_COMMAND+=" --auto --merge" fi - + echo "Executing merge command: $MERGE_COMMAND" eval $MERGE_COMMAND env: From 716842d59487679b025fe8999c8dd359f24314ff Mon Sep 17 00:00:00 2001 From: Tibo B <19124383+ingvaar@users.noreply.github.com> Date: Fri, 2 Feb 2024 18:33:21 +0100 Subject: [PATCH 04/14] feat(automerge): simplify command logic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Sören Mothes --- .github/workflows/template_automerge_dependabot.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/template_automerge_dependabot.yml b/.github/workflows/template_automerge_dependabot.yml index 9df018a..1c632a4 100644 --- a/.github/workflows/template_automerge_dependabot.yml +++ b/.github/workflows/template_automerge_dependabot.yml @@ -50,12 +50,14 @@ jobs: MERGE_COMMAND="gh pr merge \"$PR_URL\"" - if [ "${{ inputs.force }}" == 'true' ] && [ "${{ inputs.rebase }}" == 'true' ]; then - MERGE_COMMAND+=" --rebase --admin" - elif [ "${{ inputs.force }}" == 'true' ]; then - MERGE_COMMAND+=" --squash --admin" - elif [ "${{ inputs.rebase }}" == 'true' ]; then + if [ "${{ inputs.rebase }}" == 'true' ]; then MERGE_COMMAND+=" --rebase" + else + MERGE_COMMAND+=" --squash" + fi + if [ ${{ inputs.force }} == 'true' ]; then + MERGE_COMMAND+=" --admin" + fi else MERGE_COMMAND+=" --auto --merge" fi From 6c24863cf536b31743d08df9a4999688a642446a Mon Sep 17 00:00:00 2001 From: Thibaud Bonnefoy Date: Fri, 2 Feb 2024 18:34:49 +0100 Subject: [PATCH 05/14] style(automerge): remove trailing space --- .github/workflows/template_automerge_dependabot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/template_automerge_dependabot.yml b/.github/workflows/template_automerge_dependabot.yml index 1c632a4..f796b5a 100644 --- a/.github/workflows/template_automerge_dependabot.yml +++ b/.github/workflows/template_automerge_dependabot.yml @@ -57,7 +57,7 @@ jobs: fi if [ ${{ inputs.force }} == 'true' ]; then MERGE_COMMAND+=" --admin" - fi + fi else MERGE_COMMAND+=" --auto --merge" fi From 065983101db2b9380a15a163789b5e67a2de8c81 Mon Sep 17 00:00:00 2001 From: Thibaud Bonnefoy Date: Mon, 5 Feb 2024 07:46:38 +0100 Subject: [PATCH 06/14] feat(automerge): allow selection of merge strategy also update README --- .../template_automerge_dependabot.yml | 23 ++++++++++++------- README.md | 4 ++-- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/.github/workflows/template_automerge_dependabot.yml b/.github/workflows/template_automerge_dependabot.yml index f796b5a..ede03db 100644 --- a/.github/workflows/template_automerge_dependabot.yml +++ b/.github/workflows/template_automerge_dependabot.yml @@ -8,10 +8,10 @@ on: default: false required: false type: boolean - rebase: - default: false + strategy: + default: "squash" required: false - type: boolean + type: string secrets: app_id: required: true @@ -50,11 +50,18 @@ jobs: MERGE_COMMAND="gh pr merge \"$PR_URL\"" - if [ "${{ inputs.rebase }}" == 'true' ]; then - MERGE_COMMAND+=" --rebase" - else - MERGE_COMMAND+=" --squash" - fi + case "${{ inputs.strategy }}" in + "rebase") + MERGE_COMMAND+=" --rebase" + ;; + "merge") + MERGE_COMMAND+=" --merge" + ;; + *) + MERGE_COMMAND+=" --squash" + ;; + esac + if [ ${{ inputs.force }} == 'true' ]; then MERGE_COMMAND+=" --admin" fi diff --git a/README.md b/README.md index bca5c27..33c3e47 100644 --- a/README.md +++ b/README.md @@ -47,8 +47,8 @@ jobs: with: # optional: ⚠️ only enable the force merge if you want to do the merge just now force: true - # optional: enable rebase strategy when merging (default: false) - rebase: true + # optional: choose strategy when merging (default: squash) + strategy: rebase secrets: # identifier of the GitHub App for authentication app_id: ${{ }} From 348ddc93fb5c1ee86cba40f8d3dd66651550628b Mon Sep 17 00:00:00 2001 From: Thibaud Bonnefoy Date: Mon, 5 Feb 2024 08:04:21 +0100 Subject: [PATCH 07/14] feat(automerge): remove eval --- .../template_automerge_dependabot.yml | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/.github/workflows/template_automerge_dependabot.yml b/.github/workflows/template_automerge_dependabot.yml index ede03db..6e41ee6 100644 --- a/.github/workflows/template_automerge_dependabot.yml +++ b/.github/workflows/template_automerge_dependabot.yml @@ -47,30 +47,29 @@ jobs: !startsWith(steps.metadata.outputs.previous-version, '0.') run: | gh pr review --approve "$PR_URL" + + MERGE_OPTIONS='' - MERGE_COMMAND="gh pr merge \"$PR_URL\"" - - case "${{ inputs.strategy }}" in + case "$strategy" in "rebase") - MERGE_COMMAND+=" --rebase" + MERGE_OPTIONS+=" --rebase" ;; "merge") - MERGE_COMMAND+=" --merge" + MERGE_OPTIONS+=" --merge" ;; *) - MERGE_COMMAND+=" --squash" + MERGE_OPTIONS+=" --squash" ;; esac - if [ ${{ inputs.force }} == 'true' ]; then - MERGE_COMMAND+=" --admin" - fi + if [ "$force" == 'true' ]; then + MERGE_OPTIONS+=" --admin" else - MERGE_COMMAND+=" --auto --merge" + MERGE_OPTIONS+=" --auto" fi - echo "Executing merge command: $MERGE_COMMAND" - eval $MERGE_COMMAND + 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 }} From 22f96a1574bce2bcd25e284cc067d102b1b6a874 Mon Sep 17 00:00:00 2001 From: Thibaud Bonnefoy Date: Mon, 5 Feb 2024 08:05:04 +0100 Subject: [PATCH 08/14] doc(automerge): add all strategy options to README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 33c3e47..cbaaea3 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ jobs: # 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 + strategy: rebase, merge secrets: # identifier of the GitHub App for authentication app_id: ${{ }} From ead7d33a9347383cea33b5fed3db2c80d1e1583a Mon Sep 17 00:00:00 2001 From: Thibaud Bonnefoy Date: Mon, 5 Feb 2024 08:06:03 +0100 Subject: [PATCH 09/14] style(automerge): make linter happy again --- .github/workflows/template_automerge_dependabot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/template_automerge_dependabot.yml b/.github/workflows/template_automerge_dependabot.yml index 6e41ee6..62a9c51 100644 --- a/.github/workflows/template_automerge_dependabot.yml +++ b/.github/workflows/template_automerge_dependabot.yml @@ -47,7 +47,7 @@ jobs: !startsWith(steps.metadata.outputs.previous-version, '0.') run: | gh pr review --approve "$PR_URL" - + MERGE_OPTIONS='' case "$strategy" in From 36d6f90256baccfb23e1fa06c0167397365ad4f4 Mon Sep 17 00:00:00 2001 From: Thibaud Bonnefoy Date: Mon, 19 Feb 2024 10:31:53 +0100 Subject: [PATCH 10/14] fix(automerge): invert merge options and pr url --- .github/workflows/template_automerge_dependabot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/template_automerge_dependabot.yml b/.github/workflows/template_automerge_dependabot.yml index 62a9c51..d53d1be 100644 --- a/.github/workflows/template_automerge_dependabot.yml +++ b/.github/workflows/template_automerge_dependabot.yml @@ -69,7 +69,7 @@ jobs: fi echo "Executing merge command with the options: '${MERGE_OPTIONS}'" - gh pr merge "$PR_URL" "${MERGE_OPTIONS}" + gh pr merge "${MERGE_OPTIONS}" "$PR_URL" env: PR_URL: ${{ github.event.pull_request.html_url }} GITHUB_TOKEN: ${{ steps.get_token.outputs.token }} From 674a5fab711c46e86e9c55a06cb3ae6e0bf850ba Mon Sep 17 00:00:00 2001 From: Willi Mentzel Date: Sun, 10 Mar 2024 17:16:03 +0100 Subject: [PATCH 11/14] fix(automerge): URL has to come first --- .github/workflows/template_automerge_dependabot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/template_automerge_dependabot.yml b/.github/workflows/template_automerge_dependabot.yml index d53d1be..62a9c51 100644 --- a/.github/workflows/template_automerge_dependabot.yml +++ b/.github/workflows/template_automerge_dependabot.yml @@ -69,7 +69,7 @@ jobs: fi echo "Executing merge command with the options: '${MERGE_OPTIONS}'" - gh pr merge "${MERGE_OPTIONS}" "$PR_URL" + gh pr merge "$PR_URL" "${MERGE_OPTIONS}" env: PR_URL: ${{ github.event.pull_request.html_url }} GITHUB_TOKEN: ${{ steps.get_token.outputs.token }} From 37606f5ac4d5b00bc708df0dded71190fa802424 Mon Sep 17 00:00:00 2001 From: Willi Mentzel Date: Sun, 10 Mar 2024 20:16:07 +0100 Subject: [PATCH 12/14] fix(automerge): Fix command building --- .../template_automerge_dependabot.yml | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/template_automerge_dependabot.yml b/.github/workflows/template_automerge_dependabot.yml index 62a9c51..d081f91 100644 --- a/.github/workflows/template_automerge_dependabot.yml +++ b/.github/workflows/template_automerge_dependabot.yml @@ -48,28 +48,28 @@ jobs: run: | gh pr review --approve "$PR_URL" - MERGE_OPTIONS='' + MERGE_OPTIONS=() case "$strategy" in "rebase") - MERGE_OPTIONS+=" --rebase" - ;; + MERGE_OPTIONS+=("--rebase") + ;; "merge") - MERGE_OPTIONS+=" --merge" - ;; + MERGE_OPTIONS+=("--merge") + ;; *) - MERGE_OPTIONS+=" --squash" - ;; + MERGE_OPTIONS+=("--squash") + ;; esac if [ "$force" == 'true' ]; then - MERGE_OPTIONS+=" --admin" + MERGE_OPTIONS+=("--admin") else - MERGE_OPTIONS+=" --auto" + MERGE_OPTIONS+=("--auto") fi - echo "Executing merge command with the options: '${MERGE_OPTIONS}'" - gh pr merge "$PR_URL" "${MERGE_OPTIONS}" + 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 }} From 801fbe0fc304617af0d0869836d9bc2bfe2f7310 Mon Sep 17 00:00:00 2001 From: Willi Mentzel Date: Sun, 10 Mar 2024 20:31:50 +0100 Subject: [PATCH 13/14] fix(automerge): Expose "force" and "strategy" as env variables --- .github/workflows/template_automerge_dependabot.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/template_automerge_dependabot.yml b/.github/workflows/template_automerge_dependabot.yml index d081f91..107e869 100644 --- a/.github/workflows/template_automerge_dependabot.yml +++ b/.github/workflows/template_automerge_dependabot.yml @@ -50,7 +50,7 @@ jobs: MERGE_OPTIONS=() - case "$strategy" in + case "${{ env.STRATEGY }}" in "rebase") MERGE_OPTIONS+=("--rebase") ;; @@ -62,7 +62,7 @@ jobs: ;; esac - if [ "$force" == 'true' ]; then + if [ "${{ env.FORCE }}" == 'true' ]; then MERGE_OPTIONS+=("--admin") else MERGE_OPTIONS+=("--auto") @@ -73,3 +73,5 @@ jobs: env: PR_URL: ${{ github.event.pull_request.html_url }} GITHUB_TOKEN: ${{ steps.get_token.outputs.token }} + STRATEGY: ${{ inputs.strategy }} + FORCE: ${{ inputs.force }} From 9ffaa3d9fb734f62537b38d717f12d758f9f1339 Mon Sep 17 00:00:00 2001 From: Willi Mentzel Date: Mon, 11 Mar 2024 09:32:37 +0100 Subject: [PATCH 14/14] refactor(automerge): No need for env variables --- .github/workflows/template_automerge_dependabot.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/template_automerge_dependabot.yml b/.github/workflows/template_automerge_dependabot.yml index 107e869..42be77a 100644 --- a/.github/workflows/template_automerge_dependabot.yml +++ b/.github/workflows/template_automerge_dependabot.yml @@ -50,7 +50,7 @@ jobs: MERGE_OPTIONS=() - case "${{ env.STRATEGY }}" in + case "${{ inputs.strategy }}" in "rebase") MERGE_OPTIONS+=("--rebase") ;; @@ -62,7 +62,7 @@ jobs: ;; esac - if [ "${{ env.FORCE }}" == 'true' ]; then + if [ "${{ inputs.force }}" == 'true' ]; then MERGE_OPTIONS+=("--admin") else MERGE_OPTIONS+=("--auto") @@ -73,5 +73,3 @@ jobs: env: PR_URL: ${{ github.event.pull_request.html_url }} GITHUB_TOKEN: ${{ steps.get_token.outputs.token }} - STRATEGY: ${{ inputs.strategy }} - FORCE: ${{ inputs.force }}