From 970a1f01a33353642746c9feb1af53b017b26863 Mon Sep 17 00:00:00 2001 From: Ivan Goncharov Date: Wed, 10 Jun 2020 22:19:48 +0300 Subject: [PATCH] CI: various fixes in 'gitpublish.sh' --- .github/workflows/ci.yml | 2 +- resources/gitpublish.sh | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8ecfc9f23c..86458a87e1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -238,7 +238,7 @@ jobs: - name: Build Deno package run: npm run build:deno - - name: Deploy to `npm` branch + - name: Deploy to `deno` branch run: npm run gitpublish:deno env: GH_TOKEN: ${{ secrets.GH_NPM_BRANCH_PUBLISH_TOKEN }} diff --git a/resources/gitpublish.sh b/resources/gitpublish.sh index a71dbe38f3..e4ec327cae 100644 --- a/resources/gitpublish.sh +++ b/resources/gitpublish.sh @@ -14,13 +14,18 @@ DIST_DIR=$2 set -e if [ ! -d $DIST_DIR ]; then - echo "Directory `${DIST_DIR}` does not exist!" + echo "Directory '${DIST_DIR}' does not exist!" + exit 1; +fi; + +if [ -z "${GH_TOKEN}" ]; then + echo 'Must provide GH_TOKEN as environment variable!' exit 1; fi; # Create empty directory rm -rf $BRANCH -git clone -b $BRANCH "https://${GH_TOKEN}@github.com/graphql/graphql-js.git" $BRANCH +git clone -b $BRANCH -- "https://${GH_TOKEN}@github.com/graphql/graphql-js.git" $BRANCH # Remove existing files first rm -rf $BRANCH/**/* @@ -41,7 +46,7 @@ git add -A . if git diff --staged --quiet; then echo "Nothing to publish" else - git commit -a -m "Deploy $HEADREV to `$BRANCH` branch" + git commit -a -m "Deploy $HEADREV to '$BRANCH' branch" git push > /dev/null 2>&1 echo "Pushed" fi