Add simple force input

This commit is contained in:
Honza Bittner 2019-10-01 18:25:39 +02:00
parent 70ea6b82bf
commit ed911a0e24
2 changed files with 15 additions and 3 deletions

View File

@ -12,6 +12,9 @@ inputs:
description: 'Destination branch to push changes'
required: false
default: 'master'
force:
description: 'Determines if force push is used'
required: false
runs:
using: 'docker'
image: 'Dockerfile'
image: 'Dockerfile'

View File

@ -1,9 +1,18 @@
#!/bin/sh
echo "Push to branch ${INPUT_BRANCH:=master}";
INPUT_BRANCH:='master'
INPUT_FORCE:=false
_FORCE_OPTION=''
echo "Push to branch $INPUT_BRANCH";
[ -z "${INPUT_GITHUB_TOKEN}" ] && {
echo 'Missing input "github_token: ${{ secrets.GITHUB_TOKEN }}".';
exit 1;
};
if ${INPUT_FORCE}; then
_FORCE_OPTION='--force'
fi
header=$(echo -n "ad-m:${INPUT_GITHUB_TOKEN}" | base64)
git -c http.extraheader="AUTHORIZATION: basic $header" push origin HEAD:${INPUT_BRANCH} --follow-tags;
git -c http.extraheader="AUTHORIZATION: basic $header" push origin HEAD:${INPUT_BRANCH} --follow-tags $_FORCE_OPTION;