feat(merge): You can now choose to suash PRs
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Nicolai Ort 2023-05-12 12:28:33 +02:00
parent 5c7a232ffb
commit 0f39869363
Signed by: niggl
GPG Key ID: 13AFA55AF62F269F
2 changed files with 11 additions and 1 deletions

View File

@ -16,6 +16,7 @@ It is also able to merge the pull request after creation (see Settings).
* `SOURCE`: Source branch (aka head) * `SOURCE`: Source branch (aka head)
* `TARGET`: Target branch (aka base) * `TARGET`: Target branch (aka base)
* `MERGE`: Merge the PR after creation - defaults to false * `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 * `DELETE_SOURCE`: Delete source branch after merge - defaults to false
## Examples ## Examples
@ -37,5 +38,6 @@ steps:
SOURCE: dev SOURCE: dev
TARGET: main TARGET: main
MERGE: true MERGE: true
SQUASH: false
DELETE_SOURCE: false DELETE_SOURCE: false
``` ```

View File

@ -40,6 +40,14 @@ if [ "${PLUGIN_MERGE:-false}" = true ]; then
echo "Falling back to not deleting source"; echo "Falling back to not deleting source";
PLUGIN_DELETE_SOURCE=false; PLUGIN_DELETE_SOURCE=false;
fi fi
if [ "${PLUGIN_SQUASH:-null}" = null ]; then
echo "Merging PR";
ACTION="merge";
else
echo "Squashing PR";
ACTION="squash";
fi
ID=$(echo $RES | jq '.number') ID=$(echo $RES | jq '.number')
curl --request POST \ curl --request POST \
@ -48,7 +56,7 @@ if [ "${PLUGIN_MERGE:-false}" = true ]; then
--header "Authorization: token $PLUGIN_APIKEY" \ --header "Authorization: token $PLUGIN_APIKEY" \
-f \ -f \
--data "{ --data "{
\"do\": \"merge\", \"do\": \"$ACTION\",
\"delete_branch_after_merge\": $PLUGIN_DELETE_SOURCE \"delete_branch_after_merge\": $PLUGIN_DELETE_SOURCE
}" }"
echo "PR merged"; echo "PR merged";