From ed911a0e24f38ed0964068ba9e4e7fe2b081584d Mon Sep 17 00:00:00 2001 From: Honza Bittner Date: Tue, 1 Oct 2019 18:25:39 +0200 Subject: [PATCH] Add simple force input --- action.yml | 5 ++++- start.sh | 13 +++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/action.yml b/action.yml index 125afdb..23f595b 100644 --- a/action.yml +++ b/action.yml @@ -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' \ No newline at end of file + image: 'Dockerfile' diff --git a/start.sh b/start.sh index 51260d7..b5709f3 100755 --- a/start.sh +++ b/start.sh @@ -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;