From f04bd979524b74214b9cb06af51111b177fc307c Mon Sep 17 00:00:00 2001 From: Yaacov Rydzinski Date: Mon, 25 Oct 2021 21:02:49 +0300 Subject: [PATCH 1/2] Use default GITHUB_ACTOR if unset --- .github/workflows/ci.yml | 2 ++ resources/gitpublish.sh | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a6e5198510..c75fa044d0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -281,6 +281,7 @@ jobs: run: npm run gitpublish:npm env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_ACTOR: ${{ env.GITHUB_ACTOR }} deploy-to-deno-branch: name: Deploy to `deno` branch @@ -317,3 +318,4 @@ jobs: run: npm run gitpublish:deno env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_ACTOR: ${{ env.GITHUB_ACTOR }} diff --git a/resources/gitpublish.sh b/resources/gitpublish.sh index 2485143478..88e7d56b5e 100755 --- a/resources/gitpublish.sh +++ b/resources/gitpublish.sh @@ -28,6 +28,12 @@ if [ -z "${GH_TOKEN}" ]; then exit 1; fi; +if [ -z "${GH_ACTOR}" ]; then + GITHUB_CREDENTIALS="${GH_TOKEN}"; +else + GITHUB_CREDENTIALS="${GH_ACTOR}:${GH_TOKEN}"; +fi; + if [ ! -d $DIST_DIR ]; then echo "Directory '${DIST_DIR}' does not exist!" exit 1; @@ -35,7 +41,7 @@ fi; # Create empty directory rm -rf $BRANCH -git clone -b $BRANCH -- "https://${GITHUB_ACTOR}:${GH_TOKEN}@github.com/graphql/graphql-js.git" $BRANCH +git clone -b $BRANCH -- "https://${GITHUB_CREDENTIALS}@github.com/graphql/graphql-js.git" $BRANCH # Remove existing files first rm -rf $BRANCH/**/* From 3ded89ed16eb840735635032aae5d6841b0263b1 Mon Sep 17 00:00:00 2001 From: Ivan Goncharov Date: Wed, 27 Oct 2021 15:42:36 +0300 Subject: [PATCH 2/2] review changes --- .github/workflows/ci.yml | 6 ++---- resources/gitpublish.sh | 12 +++++------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c75fa044d0..eeef751331 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -280,8 +280,7 @@ jobs: - name: Deploy to `npm` branch run: npm run gitpublish:npm env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GH_ACTOR: ${{ env.GITHUB_ACTOR }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} deploy-to-deno-branch: name: Deploy to `deno` branch @@ -317,5 +316,4 @@ jobs: - name: Deploy to `deno` branch run: npm run gitpublish:deno env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GH_ACTOR: ${{ env.GITHUB_ACTOR }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/resources/gitpublish.sh b/resources/gitpublish.sh index 88e7d56b5e..bf27acdc1f 100755 --- a/resources/gitpublish.sh +++ b/resources/gitpublish.sh @@ -23,15 +23,13 @@ if [ -z "${DIST_DIR}" ]; then exit 1; fi; -if [ -z "${GH_TOKEN}" ]; then - echo 'Must provide GH_TOKEN as environment variable!' +if [ -z "${GITHUB_TOKEN}" ]; then + echo 'Must provide GITHUB_TOKEN as environment variable!' exit 1; fi; -if [ -z "${GH_ACTOR}" ]; then - GITHUB_CREDENTIALS="${GH_TOKEN}"; -else - GITHUB_CREDENTIALS="${GH_ACTOR}:${GH_TOKEN}"; +if [ -z "${GITHUB_ACTOR}" ]; then + echo 'Must provide GITHUB_ACTOR as environment variable!' fi; if [ ! -d $DIST_DIR ]; then @@ -41,7 +39,7 @@ fi; # Create empty directory rm -rf $BRANCH -git clone -b $BRANCH -- "https://${GITHUB_CREDENTIALS}@github.com/graphql/graphql-js.git" $BRANCH +git clone -b $BRANCH -- "https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/graphql/graphql-js.git" $BRANCH # Remove existing files first rm -rf $BRANCH/**/*