Add support for changing directories before push

This commit is contained in:
Oliver Kopp
2019-10-01 21:42:53 +02:00
parent 1c8b858b13
commit a8bfc1909c
3 changed files with 14 additions and 2 deletions

View File

@@ -1,7 +1,9 @@
#!/bin/sh
set -e
INPUT_BRANCH:='master'
INPUT_FORCE:=false
INPUT_BRANCH=${INPUT_BRANCH:-master}
INPUT_FORCE=${INPUT_FORCE:-false}
INPUT_DIRECTORY=${INPUT_DIRECTORY:-'.'}
_FORCE_OPTION=''
echo "Push to branch $INPUT_BRANCH";
@@ -14,5 +16,10 @@ if ${INPUT_FORCE}; then
_FORCE_OPTION='--force'
fi
cd ${INPUT_DIRECTORY}
# Ensure that the remote of the git repository of the current directory still is the repository where the github action is executed
git remote add origin https://github.com/${GITHUB_REPOSITORY} || git remote set-url origin https://github.com/${GITHUB_REPOSITORY} || true
header=$(echo -n "ad-m:${INPUT_GITHUB_TOKEN}" | base64)
git -c http.extraheader="AUTHORIZATION: basic $header" push origin HEAD:${INPUT_BRANCH} --follow-tags $_FORCE_OPTION;