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

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)
* `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
```

View File

@ -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";