diff --git a/README.md b/README.md index 3a56ca0..2de1556 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ It is also able to merge the pull request after creation (see Settings). * `SOURCE`: Source branch (aka head) * `TARGET`: Target branch (aka base) * `MERGE`: Merge the PR after creation - defaults to false +* `SQUASH`: Suash the merge - defaults to false * `DELETE_SOURCE`: Delete source branch after merge - defaults to false ## Examples @@ -37,5 +38,6 @@ steps: SOURCE: dev TARGET: main MERGE: true + SQUASH: false DELETE_SOURCE: false ``` \ No newline at end of file diff --git a/plugin.sh b/plugin.sh index 1326ff0..21b1d8e 100644 --- a/plugin.sh +++ b/plugin.sh @@ -40,6 +40,14 @@ if [ "${PLUGIN_MERGE:-false}" = true ]; then echo "Falling back to not deleting source"; PLUGIN_DELETE_SOURCE=false; fi + + if [ "${PLUGIN_SQUASH:-null}" = null ]; then + echo "Merging PR"; + ACTION="merge"; + else + echo "Squashing PR"; + ACTION="squash"; + fi ID=$(echo $RES | jq '.number') curl --request POST \ @@ -48,7 +56,7 @@ if [ "${PLUGIN_MERGE:-false}" = true ]; then --header "Authorization: token $PLUGIN_APIKEY" \ -f \ --data "{ - \"do\": \"merge\", + \"do\": \"$ACTION\", \"delete_branch_after_merge\": $PLUGIN_DELETE_SOURCE }" echo "PR merged";