diff --git a/entrypoint.sh b/entrypoint.sh index 0b7b7e84a..efd7062f8 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -2,21 +2,21 @@ set -e -if [[ -z "$GITHUB_TOKEN" ]]; then +if [ -z "$GITHUB_TOKEN" ]; then echo "Set the GITHUB_TOKEN environment variable." exit 1 fi -if [[ ! -z "$SSH_PRIVATE_KEY" ]]; then +if [ ! -z "$SSH_PRIVATE_KEY" ]; then echo "Saving SSH_PRIVATE_KEY" - mkdir --parents /root/.ssh + mkdir -p /root/.ssh echo "$SSH_PRIVATE_KEY" > /root/.ssh/id_rsa chmod 600 /root/.ssh/id_rsa # Github action changes $HOME to /github at runtime # therefore we always copy the SSH key to $HOME (aka. ~) - mkdir --parents ~/.ssh + mkdir -p ~/.ssh cp /root/.ssh/* ~/.ssh/ 2> /dev/null || true fi diff --git a/github-sync.sh b/github-sync.sh index 845013dcf..54b19f5aa 100755 --- a/github-sync.sh +++ b/github-sync.sh @@ -5,17 +5,17 @@ set -e UPSTREAM_REPO=$1 BRANCH_MAPPING=$2 -if [[ -z "$UPSTREAM_REPO" ]]; then +if [ -z "$UPSTREAM_REPO" ]; then echo "Missing \$UPSTREAM_REPO" exit 1 fi -if [[ -z "$BRANCH_MAPPING" ]]; then +if [ -z "$BRANCH_MAPPING" ]; then echo "Missing \$SOURCE_BRANCH:\$DESTINATION_BRANCH" exit 1 fi -if ! echo $UPSTREAM_REPO | grep -Eq ':|@|\.git\/?$' +if ! echo "$UPSTREAM_REPO" | grep -Eq ':|@|\.git\/?$' then echo "UPSTREAM_REPO does not seem to be a valid git URI, assuming it's a GitHub repo" echo "Originally: $UPSTREAM_REPO" @@ -41,14 +41,14 @@ git remote --verbose echo "Pushing changings from tmp_upstream to origin" git push origin "refs/remotes/tmp_upstream/${BRANCH_MAPPING%%:*}:refs/heads/${BRANCH_MAPPING#*:}" --force -if [[ "$SYNC_TAGS" = true ]]; then +if [ "$SYNC_TAGS" = true ]; then echo "Force syncing all tags" - git tag -d $(git tag -l) > /dev/null + git tag -d "$(git tag -l)" > /dev/null git fetch tmp_upstream --tags --quiet git push origin --tags --force -elif [[ -n "$SYNC_TAGS" ]]; then +elif [ -n "$SYNC_TAGS" ]; then echo "Force syncing tags matching pattern: $SYNC_TAGS" - git tag -d $(git tag -l) > /dev/null + git tag -d "$(git tag -l)" > /dev/null git fetch tmp_upstream --tags --quiet git tag | grep "$SYNC_TAGS" | xargs --no-run-if-empty git push origin --force fi