From 44874b4491007792e25f343663ca88641530d0fd Mon Sep 17 00:00:00 2001 From: Adam Silverstein Date: Tue, 25 Feb 2020 11:46:08 -0700 Subject: [PATCH 01/23] Add actions to build PRs and develop, cleanup closed PRs. --- .github/release-to-wiki.sh | 28 ++++++++++++++ .github/remove-from-wiki.sh | 25 +++++++++++++ .github/workflows/build-pr.yml | 65 +++++++++++++++++++++++++++++++++ .github/workflows/remove-pr.yml | 14 +++++++ 4 files changed, 132 insertions(+) create mode 100644 .github/release-to-wiki.sh create mode 100644 .github/remove-from-wiki.sh create mode 100644 .github/workflows/build-pr.yml create mode 100644 .github/workflows/remove-pr.yml diff --git a/.github/release-to-wiki.sh b/.github/release-to-wiki.sh new file mode 100644 index 00000000000..1b769363158 --- /dev/null +++ b/.github/release-to-wiki.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +GIT_REPOSITORY_URL="https://${GITHUB_PERSONAL_ACCESS_TOKEN}@github.com/$GITHUB_REPOSITORY.wiki.git" + +tmp_dir=$(mktemp -d -t ci-XXXXXXXXXX) +( + cd "$tmp_dir" || exit 1 + git init + git config user.name "$GITHUB_ACTOR" + git config user.email "$GITHUB_ACTOR@users.noreply.github.com" + git pull "$GIT_REPOSITORY_URL" +) + +mkdir -p "$tmp_dir/$1" +for file in $(find $1 -maxdepth 1 -type f -name '*' -execdir basename '{}' ';'); do + cp "$1/$file" "$tmp_dir/$1" +done + +echo "Publishing build files for $1" +( + cd "$tmp_dir" || exit 1 + git add . + git commit -m "Build and publish $1" + git push --set-upstream "$GIT_REPOSITORY_URL" master +) + +rm -rf "$tmp_dir" +exit 0 \ No newline at end of file diff --git a/.github/remove-from-wiki.sh b/.github/remove-from-wiki.sh new file mode 100644 index 00000000000..040c0a632af --- /dev/null +++ b/.github/remove-from-wiki.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +GIT_REPOSITORY_URL="https://${GITHUB_PERSONAL_ACCESS_TOKEN}@github.com/$GITHUB_REPOSITORY.wiki.git" + +echo "Checking out wiki repository" +tmp_dir=$(mktemp -d -t ci-XXXXXXXXXX) +( + cd "$tmp_dir" || exit 1 + git init + git config user.name "$GITHUB_ACTOR" + git config user.email "$GITHUB_ACTOR@users.noreply.github.com" + git pull "$GIT_REPOSITORY_URL" +) + +rm -Rf "$tmp_dir/$1" + +echo "Removing build files from $1" +( + cd "$tmp_dir" || exit 1 + git commit -m "$WIKI_COMMIT_MESSAGE" + git push --set-upstream "$GIT_REPOSITORY_URL" master +) + +rm -rf "$tmp_dir" +exit 0 \ No newline at end of file diff --git a/.github/workflows/build-pr.yml b/.github/workflows/build-pr.yml new file mode 100644 index 00000000000..c5677fa2c3e --- /dev/null +++ b/.github/workflows/build-pr.yml @@ -0,0 +1,65 @@ +name: build-pr + +on: + push: + branches: + - develop + pull_request: + +jobs: + build-pr: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Get Composer Cache Directory + id: composer-cache + run: | + echo "::set-output name=dir::$(composer config cache-files-dir)" + - uses: actions/cache@v1 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-composer- + - name: Composer Install + uses: php-actions/composer@v1 + with: + args: install + - name: Setup Node.js 10 + uses: actions/setup-node@v1 + with: + node-version: '10.x' + - name: Cache Node - npm + uses: actions/cache@v1 + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node-cache- + - name: npm/Gulp Install + run: | + npm install + npm install gulp-cli -g + - name: Build develop version + run: | + npm run build:dev + gulp release + gulp copy + gulp pre-zip + gulp zip + mv google-site-kit.zip google-site-kit-dev.zip + - name: Build release version + run: | + npm run build + gulp release + gulp copy + gulp pre-zip + gulp zip + - name: Deploy build files to wiki + run: | + mkdir -p ${{ github.ref }} + mv google-site-kit.zip ${{ github.ref }} + mv google-site-kit-dev.zip ${{ github.ref }} + bash .github/release-to-wiki.sh ${{ github.ref }} + env: + GITHUB_PERSONAL_ACCESS_TOKEN: ${{ secrets.GITHUB_PERSONAL_ACCESS_TOKEN }} diff --git a/.github/workflows/remove-pr.yml b/.github/workflows/remove-pr.yml new file mode 100644 index 00000000000..f4e2145820c --- /dev/null +++ b/.github/workflows/remove-pr.yml @@ -0,0 +1,14 @@ +name: remove-pr + +on: + pull_request: + types: [closed] +jobs: + remove-pr: + runs-on: ubuntu-latest + steps: + - name: Repository Dispatch + run: | + bash .github/remove-from-wiki.sh ${{ github.ref }} + env: + GITHUB_PERSONAL_ACCESS_TOKEN: ${{ secrets.GITHUB_PERSONAL_ACCESS_TOKEN }} From 2907354d00597a1415df72c17bf3dff32c6fd06a Mon Sep 17 00:00:00 2001 From: Adam Silverstein Date: Tue, 25 Feb 2020 15:34:47 -0700 Subject: [PATCH 02/23] adjust build command for new dynamic zip file naming --- .github/workflows/build-pr.yml | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build-pr.yml b/.github/workflows/build-pr.yml index c5677fa2c3e..db4672032bc 100644 --- a/.github/workflows/build-pr.yml +++ b/.github/workflows/build-pr.yml @@ -43,18 +43,13 @@ jobs: - name: Build develop version run: | npm run build:dev - gulp release - gulp copy - gulp pre-zip - gulp zip - mv google-site-kit.zip google-site-kit-dev.zip + ZIP=`gulp release | grep Creating | cut -c10-` + mv "$ZIP" google-site-kit-dev.zip - name: Build release version run: | npm run build - gulp release - gulp copy - gulp pre-zip - gulp zip + ZIP=`gulp release | grep Creating | cut -c10-` + mv "$ZIP" google-site-kit.zip - name: Deploy build files to wiki run: | mkdir -p ${{ github.ref }} From 5d2f2de7543f53948cde7d60d019b5ad178879b2 Mon Sep 17 00:00:00 2001 From: Adam Silverstein Date: Fri, 28 Feb 2020 08:30:24 -0700 Subject: [PATCH 03/23] use npm command for zip build --- .github/workflows/build-pr.yml | 5 ++--- package.json | 1 + 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-pr.yml b/.github/workflows/build-pr.yml index db4672032bc..e5762e0e524 100644 --- a/.github/workflows/build-pr.yml +++ b/.github/workflows/build-pr.yml @@ -42,13 +42,12 @@ jobs: npm install gulp-cli -g - name: Build develop version run: | - npm run build:dev - ZIP=`gulp release | grep Creating | cut -c10-` + ZIP=`npm run release-zip | grep Creating | cut -c10-` mv "$ZIP" google-site-kit-dev.zip - name: Build release version run: | npm run build - ZIP=`gulp release | grep Creating | cut -c10-` + ZIP=`npm run dev-zip | grep Creating | cut -c10-` mv "$ZIP" google-site-kit.zip - name: Deploy build files to wiki run: | diff --git a/package.json b/package.json index ef079802930..03e692a7be4 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "build:dev": "npm run build:static && webpack --mode=development --debug --devtool cheap-source-map --output-pathinfo", "build:static": "gulp svg imagemin", "dev": "npm run build:dev && npm run build:static", + "dev-zip": "npm run build:dev && gulp release", "watch": "npm run remove-dist && npm run build:static && webpack --watch --mode=development --debug --devtool cheap-module-eval-source-map --output-pathinfo", "release-zip": "npm run build && gulp release", "remove-dist": "rm -rf dist/*", From fcd7b1c6c11a6263c03d611be4864eac00aa3a77 Mon Sep 17 00:00:00 2001 From: Adam Silverstein Date: Fri, 28 Feb 2020 10:09:03 -0700 Subject: [PATCH 04/23] Use node version from .nvmrc --- .github/workflows/build-pr.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-pr.yml b/.github/workflows/build-pr.yml index e5762e0e524..6fa8e4c6623 100644 --- a/.github/workflows/build-pr.yml +++ b/.github/workflows/build-pr.yml @@ -25,10 +25,13 @@ jobs: uses: php-actions/composer@v1 with: args: install - - name: Setup Node.js 10 + - name: Read .nvmrc + run: echo "##[set-output name=NVMRC;]$(cat .nvmrc)" + id: nvm + - name: Setup Node.js (.nvmrc) uses: actions/setup-node@v1 with: - node-version: '10.x' + node-version: "${{ steps.nvm.outputs.NVMRC }}" - name: Cache Node - npm uses: actions/cache@v1 with: From caed4bc79744930ccf641f33ba3a2b33e69e35f8 Mon Sep 17 00:00:00 2001 From: Adam Silverstein Date: Fri, 28 Feb 2020 10:29:07 -0700 Subject: [PATCH 05/23] Remove gulp install. --- .github/workflows/build-pr.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build-pr.yml b/.github/workflows/build-pr.yml index 6fa8e4c6623..2bb33cfd056 100644 --- a/.github/workflows/build-pr.yml +++ b/.github/workflows/build-pr.yml @@ -39,10 +39,9 @@ jobs: key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} restore-keys: | ${{ runner.os }}-node-cache- - - name: npm/Gulp Install + - name: npm install run: | npm install - npm install gulp-cli -g - name: Build develop version run: | ZIP=`npm run release-zip | grep Creating | cut -c10-` From 6f0fdf233dc45f2dbf08808e8f406afe03347632 Mon Sep 17 00:00:00 2001 From: Adam Silverstein Date: Fri, 28 Feb 2020 10:34:28 -0700 Subject: [PATCH 06/23] Assign $1 to GIT_REF. --- .github/release-to-wiki.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/release-to-wiki.sh b/.github/release-to-wiki.sh index 1b769363158..333e41f8939 100644 --- a/.github/release-to-wiki.sh +++ b/.github/release-to-wiki.sh @@ -1,7 +1,7 @@ #!/bin/bash GIT_REPOSITORY_URL="https://${GITHUB_PERSONAL_ACCESS_TOKEN}@github.com/$GITHUB_REPOSITORY.wiki.git" - +GIT_REF="$1" tmp_dir=$(mktemp -d -t ci-XXXXXXXXXX) ( cd "$tmp_dir" || exit 1 @@ -11,16 +11,16 @@ tmp_dir=$(mktemp -d -t ci-XXXXXXXXXX) git pull "$GIT_REPOSITORY_URL" ) -mkdir -p "$tmp_dir/$1" -for file in $(find $1 -maxdepth 1 -type f -name '*' -execdir basename '{}' ';'); do - cp "$1/$file" "$tmp_dir/$1" +mkdir -p "$tmp_dir/${GIT_REF}" +for file in $(find ${GIT_REF} -maxdepth 1 -type f -name '*' -execdir basename '{}' ';'); do + cp "${GIT_REF}/$file" "$tmp_dir/${GIT_REF}" done -echo "Publishing build files for $1" +echo "Publishing build files for ${GIT_REF}" ( cd "$tmp_dir" || exit 1 git add . - git commit -m "Build and publish $1" + git commit -m "Build and publish ${GIT_REF}" git push --set-upstream "$GIT_REPOSITORY_URL" master ) From b3612da536cc21bf2aa6976c457c9dd91b6c92fe Mon Sep 17 00:00:00 2001 From: Adam Silverstein Date: Fri, 28 Feb 2020 10:38:00 -0700 Subject: [PATCH 07/23] Move GIT_REF to env. --- .github/release-to-wiki.sh | 1 - .github/workflows/build-pr.yml | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/release-to-wiki.sh b/.github/release-to-wiki.sh index 333e41f8939..93a1bb247bb 100644 --- a/.github/release-to-wiki.sh +++ b/.github/release-to-wiki.sh @@ -1,7 +1,6 @@ #!/bin/bash GIT_REPOSITORY_URL="https://${GITHUB_PERSONAL_ACCESS_TOKEN}@github.com/$GITHUB_REPOSITORY.wiki.git" -GIT_REF="$1" tmp_dir=$(mktemp -d -t ci-XXXXXXXXXX) ( cd "$tmp_dir" || exit 1 diff --git a/.github/workflows/build-pr.yml b/.github/workflows/build-pr.yml index 2bb33cfd056..34d0e5f7c59 100644 --- a/.github/workflows/build-pr.yml +++ b/.github/workflows/build-pr.yml @@ -56,6 +56,7 @@ jobs: mkdir -p ${{ github.ref }} mv google-site-kit.zip ${{ github.ref }} mv google-site-kit-dev.zip ${{ github.ref }} - bash .github/release-to-wiki.sh ${{ github.ref }} + bash .github/release-to-wiki.sh env: GITHUB_PERSONAL_ACCESS_TOKEN: ${{ secrets.GITHUB_PERSONAL_ACCESS_TOKEN }} + GIT_REF: ${{ github.ref }} From 36f4963061f0d3d9739cb635df5c7ed57a4ded4c Mon Sep 17 00:00:00 2001 From: Adam Silverstein Date: Fri, 28 Feb 2020 10:38:16 -0700 Subject: [PATCH 08/23] Base tmp dir name on git ref. --- .github/release-to-wiki.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/release-to-wiki.sh b/.github/release-to-wiki.sh index 93a1bb247bb..eedd2ee28d8 100644 --- a/.github/release-to-wiki.sh +++ b/.github/release-to-wiki.sh @@ -1,7 +1,7 @@ #!/bin/bash GIT_REPOSITORY_URL="https://${GITHUB_PERSONAL_ACCESS_TOKEN}@github.com/$GITHUB_REPOSITORY.wiki.git" -tmp_dir=$(mktemp -d -t ci-XXXXXXXXXX) +tmp_dir="/tmp/build/${GIT_REF}" ( cd "$tmp_dir" || exit 1 git init From 93a438c2d1635b2713de5ae462b752f71f0cf635 Mon Sep 17 00:00:00 2001 From: Adam Silverstein Date: Fri, 28 Feb 2020 10:45:06 -0700 Subject: [PATCH 09/23] Clean up copy command. --- .github/release-to-wiki.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/release-to-wiki.sh b/.github/release-to-wiki.sh index eedd2ee28d8..4d09d1bf88b 100644 --- a/.github/release-to-wiki.sh +++ b/.github/release-to-wiki.sh @@ -4,10 +4,9 @@ GIT_REPOSITORY_URL="https://${GITHUB_PERSONAL_ACCESS_TOKEN}@github.com/$GITHUB_R tmp_dir="/tmp/build/${GIT_REF}" ( cd "$tmp_dir" || exit 1 - git init + git clone "$GIT_REPOSITORY_URL" git config user.name "$GITHUB_ACTOR" git config user.email "$GITHUB_ACTOR@users.noreply.github.com" - git pull "$GIT_REPOSITORY_URL" ) mkdir -p "$tmp_dir/${GIT_REF}" From 72c853e3d09f20b7fb83fccd876e8d3b9c7a2aa3 Mon Sep 17 00:00:00 2001 From: Adam Silverstein Date: Fri, 28 Feb 2020 10:49:27 -0700 Subject: [PATCH 10/23] Remove action: pass ref to bash script via env. --- .github/remove-from-wiki.sh | 9 ++++----- .github/workflows/remove-pr.yml | 3 ++- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/remove-from-wiki.sh b/.github/remove-from-wiki.sh index 040c0a632af..a6dd47f49f8 100644 --- a/.github/remove-from-wiki.sh +++ b/.github/remove-from-wiki.sh @@ -3,18 +3,17 @@ GIT_REPOSITORY_URL="https://${GITHUB_PERSONAL_ACCESS_TOKEN}@github.com/$GITHUB_REPOSITORY.wiki.git" echo "Checking out wiki repository" -tmp_dir=$(mktemp -d -t ci-XXXXXXXXXX) +tmp_dir="/tmp/build/${GIT_REF}" ( cd "$tmp_dir" || exit 1 - git init + git clone "$GIT_REPOSITORY_URL" git config user.name "$GITHUB_ACTOR" git config user.email "$GITHUB_ACTOR@users.noreply.github.com" - git pull "$GIT_REPOSITORY_URL" ) -rm -Rf "$tmp_dir/$1" +rm -Rf "$tmp_dir/${GIT_REF}" -echo "Removing build files from $1" +echo "Removing build files from ${GIT_REF}" ( cd "$tmp_dir" || exit 1 git commit -m "$WIKI_COMMIT_MESSAGE" diff --git a/.github/workflows/remove-pr.yml b/.github/workflows/remove-pr.yml index f4e2145820c..adc7358159a 100644 --- a/.github/workflows/remove-pr.yml +++ b/.github/workflows/remove-pr.yml @@ -9,6 +9,7 @@ jobs: steps: - name: Repository Dispatch run: | - bash .github/remove-from-wiki.sh ${{ github.ref }} + bash .github/remove-from-wiki.sh env: GITHUB_PERSONAL_ACCESS_TOKEN: ${{ secrets.GITHUB_PERSONAL_ACCESS_TOKEN }} + GIT_REF: ${{ github.ref }} From fec6cca6a7ceea426a903f16fdba020ac46c3082 Mon Sep 17 00:00:00 2001 From: Adam Silverstein Date: Fri, 28 Feb 2020 10:49:43 -0700 Subject: [PATCH 11/23] Clean up copy command. --- .github/release-to-wiki.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/release-to-wiki.sh b/.github/release-to-wiki.sh index 4d09d1bf88b..28f0e479315 100644 --- a/.github/release-to-wiki.sh +++ b/.github/release-to-wiki.sh @@ -10,9 +10,7 @@ tmp_dir="/tmp/build/${GIT_REF}" ) mkdir -p "$tmp_dir/${GIT_REF}" -for file in $(find ${GIT_REF} -maxdepth 1 -type f -name '*' -execdir basename '{}' ';'); do - cp "${GIT_REF}/$file" "$tmp_dir/${GIT_REF}" -done +cp "${GIT_REF}/*.zip" "$tmp_dir/${GIT_REF}" echo "Publishing build files for ${GIT_REF}" ( From 30ed8e456cb385525e32132d7c04ed1973b2fc45 Mon Sep 17 00:00:00 2001 From: Adam Silverstein Date: Fri, 28 Feb 2020 10:56:38 -0700 Subject: [PATCH 12/23] Correct git commands. --- .github/release-to-wiki.sh | 6 ++++-- .github/remove-from-wiki.sh | 3 ++- .github/workflows/build-pr.yml | 2 ++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/release-to-wiki.sh b/.github/release-to-wiki.sh index 28f0e479315..ecc2829df5a 100644 --- a/.github/release-to-wiki.sh +++ b/.github/release-to-wiki.sh @@ -2,15 +2,17 @@ GIT_REPOSITORY_URL="https://${GITHUB_PERSONAL_ACCESS_TOKEN}@github.com/$GITHUB_REPOSITORY.wiki.git" tmp_dir="/tmp/build/${GIT_REF}" +mkdir -p "$tmp_dir" ( cd "$tmp_dir" || exit 1 - git clone "$GIT_REPOSITORY_URL" + git clone "$GIT_REPOSITORY_URL" . git config user.name "$GITHUB_ACTOR" git config user.email "$GITHUB_ACTOR@users.noreply.github.com" ) mkdir -p "$tmp_dir/${GIT_REF}" -cp "${GIT_REF}/*.zip" "$tmp_dir/${GIT_REF}" +ls "${GIT_REF}" +cp "${GIT_REF}/"* "$tmp_dir/${GIT_REF}" echo "Publishing build files for ${GIT_REF}" ( diff --git a/.github/remove-from-wiki.sh b/.github/remove-from-wiki.sh index a6dd47f49f8..63a25465c5f 100644 --- a/.github/remove-from-wiki.sh +++ b/.github/remove-from-wiki.sh @@ -4,9 +4,10 @@ GIT_REPOSITORY_URL="https://${GITHUB_PERSONAL_ACCESS_TOKEN}@github.com/$GITHUB_R echo "Checking out wiki repository" tmp_dir="/tmp/build/${GIT_REF}" +mkdir -p "$tmp_dir" ( cd "$tmp_dir" || exit 1 - git clone "$GIT_REPOSITORY_URL" + git clone "$GIT_REPOSITORY_URL" . git config user.name "$GITHUB_ACTOR" git config user.email "$GITHUB_ACTOR@users.noreply.github.com" ) diff --git a/.github/workflows/build-pr.yml b/.github/workflows/build-pr.yml index 34d0e5f7c59..9ef7b14a92d 100644 --- a/.github/workflows/build-pr.yml +++ b/.github/workflows/build-pr.yml @@ -45,11 +45,13 @@ jobs: - name: Build develop version run: | ZIP=`npm run release-zip | grep Creating | cut -c10-` + echo "built $ZIP" mv "$ZIP" google-site-kit-dev.zip - name: Build release version run: | npm run build ZIP=`npm run dev-zip | grep Creating | cut -c10-` + echo "built $ZIP" mv "$ZIP" google-site-kit.zip - name: Deploy build files to wiki run: | From 64bbc86ea9531c9a250aac0c87c087ed4b2cb08a Mon Sep 17 00:00:00 2001 From: Adam Silverstein Date: Fri, 28 Feb 2020 13:30:34 -0700 Subject: [PATCH 13/23] Clean up mv commands. --- .github/workflows/build-pr.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-pr.yml b/.github/workflows/build-pr.yml index 9ef7b14a92d..cb7ab13f9f3 100644 --- a/.github/workflows/build-pr.yml +++ b/.github/workflows/build-pr.yml @@ -44,15 +44,12 @@ jobs: npm install - name: Build develop version run: | - ZIP=`npm run release-zip | grep Creating | cut -c10-` - echo "built $ZIP" - mv "$ZIP" google-site-kit-dev.zip + npm run dev-zip + mv *.zip google-site-kit-dev.zip - name: Build release version run: | - npm run build - ZIP=`npm run dev-zip | grep Creating | cut -c10-` - echo "built $ZIP" - mv "$ZIP" google-site-kit.zip + npm run release-zip + mv *.zip google-site-kit.zip - name: Deploy build files to wiki run: | mkdir -p ${{ github.ref }} From d048a3279dd7e7aca4e9a6a55a3b9402acb8463b Mon Sep 17 00:00:00 2001 From: Adam Silverstein Date: Fri, 28 Feb 2020 13:34:02 -0700 Subject: [PATCH 14/23] Copy built files into place. --- .github/workflows/build-pr.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-pr.yml b/.github/workflows/build-pr.yml index cb7ab13f9f3..c05b376d837 100644 --- a/.github/workflows/build-pr.yml +++ b/.github/workflows/build-pr.yml @@ -42,19 +42,18 @@ jobs: - name: npm install run: | npm install + - name: Create destination directory + run: mkdir -p ${{ github.ref }} - name: Build develop version run: | npm run dev-zip - mv *.zip google-site-kit-dev.zip + mv *.zip ${{ github.ref }}/google-site-kit-dev.zip - name: Build release version run: | npm run release-zip - mv *.zip google-site-kit.zip + mv *.zip ${{ github.ref }}/google-site-kit.zip - name: Deploy build files to wiki run: | - mkdir -p ${{ github.ref }} - mv google-site-kit.zip ${{ github.ref }} - mv google-site-kit-dev.zip ${{ github.ref }} bash .github/release-to-wiki.sh env: GITHUB_PERSONAL_ACCESS_TOKEN: ${{ secrets.GITHUB_PERSONAL_ACCESS_TOKEN }} From d1073c820efd358a36bfa5e513b23e7e1251fbd8 Mon Sep 17 00:00:00 2001 From: Evan Mattson Date: Fri, 28 Feb 2020 22:40:36 +0200 Subject: [PATCH 15/23] Clean dist when performing a dev build. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ec84fca9ab4..77edec1bef1 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "build": "npm run remove-dist && npm run build:production && npm run build:static", "build:production": "webpack -p --mode=production", "build:test": "webpack -p --mode=production --include-tests", - "build:dev": "npm run build:static && webpack --mode=development --debug --devtool cheap-source-map --output-pathinfo", + "build:dev": "npm run remove-dist && npm run build:static && webpack --mode=development --debug --devtool cheap-source-map --output-pathinfo", "build:static": "gulp svg imagemin", "dev": "npm run build:dev && npm run build:static", "dev-zip": "npm run build:dev && gulp release", From 05453459f3080979046e08726b894f7620638c8d Mon Sep 17 00:00:00 2001 From: Evan Mattson Date: Fri, 28 Feb 2020 22:50:11 +0200 Subject: [PATCH 16/23] Shallow clone wiki repo for efficiency. --- .github/release-to-wiki.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/release-to-wiki.sh b/.github/release-to-wiki.sh index ecc2829df5a..072b1bc936e 100644 --- a/.github/release-to-wiki.sh +++ b/.github/release-to-wiki.sh @@ -5,7 +5,7 @@ tmp_dir="/tmp/build/${GIT_REF}" mkdir -p "$tmp_dir" ( cd "$tmp_dir" || exit 1 - git clone "$GIT_REPOSITORY_URL" . + git clone --depth 1 "$GIT_REPOSITORY_URL" . git config user.name "$GITHUB_ACTOR" git config user.email "$GITHUB_ACTOR@users.noreply.github.com" ) @@ -23,4 +23,4 @@ echo "Publishing build files for ${GIT_REF}" ) rm -rf "$tmp_dir" -exit 0 \ No newline at end of file +exit 0 From 0cee859c528dab4312fa406c161ac18989e47bb2 Mon Sep 17 00:00:00 2001 From: Evan Mattson Date: Sat, 29 Feb 2020 11:30:58 +0200 Subject: [PATCH 17/23] Deploy to wiki in dedicated job using artifacts. --- .github/workflows/build-pr.yml | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-pr.yml b/.github/workflows/build-pr.yml index c05b376d837..ba8ec9d078f 100644 --- a/.github/workflows/build-pr.yml +++ b/.github/workflows/build-pr.yml @@ -51,10 +51,28 @@ jobs: - name: Build release version run: | npm run release-zip - mv *.zip ${{ github.ref }}/google-site-kit.zip - - name: Deploy build files to wiki - run: | - bash .github/release-to-wiki.sh - env: - GITHUB_PERSONAL_ACCESS_TOKEN: ${{ secrets.GITHUB_PERSONAL_ACCESS_TOKEN }} - GIT_REF: ${{ github.ref }} + # mv *.zip ${{ github.ref }}/google-site-kit.zip + - name: Upload artifacts + uses: actions/upload-artifact@v1 + with: + name: zip-files + path: ${{ github.ref }} + + deploy-to-wiki: + runs-on: ubuntu-latest + needs: build-pr + steps: + - uses: actions/checkout@v2 + with: + repository: ${{ github.repository }}.wiki + - name: Download artifacts + uses: actions/download-artifact@v1 + with: + name: zip-files + path: ${{ github.ref }} + - name: Commit updates + run: | + git add . + git status + git commit -m "Build and publish ${{ github.ref }}" + git log --name-status HEAD^..HEAD \ No newline at end of file From 0d5da4a9340eb5bfe7f0ebfe096dc438b4b4075f Mon Sep 17 00:00:00 2001 From: Evan Mattson Date: Sat, 29 Feb 2020 12:16:22 +0200 Subject: [PATCH 18/23] Add release zip. --- .github/workflows/build-pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-pr.yml b/.github/workflows/build-pr.yml index ba8ec9d078f..93f79414008 100644 --- a/.github/workflows/build-pr.yml +++ b/.github/workflows/build-pr.yml @@ -51,7 +51,7 @@ jobs: - name: Build release version run: | npm run release-zip - # mv *.zip ${{ github.ref }}/google-site-kit.zip + mv *.zip ${{ github.ref }}/google-site-kit.zip - name: Upload artifacts uses: actions/upload-artifact@v1 with: From b4cac9efe008dd44b7515c336338def16c814ea9 Mon Sep 17 00:00:00 2001 From: Evan Mattson Date: Sat, 29 Feb 2020 12:20:15 +0200 Subject: [PATCH 19/23] Set git commit info and test push. --- .github/workflows/build-pr.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-pr.yml b/.github/workflows/build-pr.yml index 93f79414008..60237158486 100644 --- a/.github/workflows/build-pr.yml +++ b/.github/workflows/build-pr.yml @@ -75,4 +75,10 @@ jobs: git add . git status git commit -m "Build and publish ${{ github.ref }}" - git log --name-status HEAD^..HEAD \ No newline at end of file + git log --name-status HEAD^..HEAD + git push origin master --dry-run + env: + GIT_AUTHOR_EMAIL=${{ github.actor }}@users.noreply.github.com + GIT_AUTHOR_NAME=${{ github.actor }} + GIT_COMMITTER_EMAIL=${{ github.actor }}@users.noreply.github.com + GIT_COMMITTER_NAME=${{ github.actor }} From 5f2a962671344b29257fc848767841fee4ce4b13 Mon Sep 17 00:00:00 2001 From: Evan Mattson Date: Sat, 29 Feb 2020 12:29:21 +0200 Subject: [PATCH 20/23] Fix env syntax. --- .github/workflows/build-pr.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-pr.yml b/.github/workflows/build-pr.yml index 60237158486..36d13c06720 100644 --- a/.github/workflows/build-pr.yml +++ b/.github/workflows/build-pr.yml @@ -78,7 +78,7 @@ jobs: git log --name-status HEAD^..HEAD git push origin master --dry-run env: - GIT_AUTHOR_EMAIL=${{ github.actor }}@users.noreply.github.com - GIT_AUTHOR_NAME=${{ github.actor }} - GIT_COMMITTER_EMAIL=${{ github.actor }}@users.noreply.github.com - GIT_COMMITTER_NAME=${{ github.actor }} + GIT_AUTHOR_EMAIL: ${{ github.actor }}@users.noreply.github.com + GIT_AUTHOR_NAME: ${{ github.actor }} + GIT_COMMITTER_EMAIL: ${{ github.actor }}@users.noreply.github.com + GIT_COMMITTER_NAME: ${{ github.actor }} From 1c22b827bd8be0fd0539c745951faa01933d9ed5 Mon Sep 17 00:00:00 2001 From: Evan Mattson Date: Sat, 29 Feb 2020 12:43:11 +0200 Subject: [PATCH 21/23] Push zips to wiki. --- .github/workflows/build-pr.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build-pr.yml b/.github/workflows/build-pr.yml index 36d13c06720..dc7ac6b55dc 100644 --- a/.github/workflows/build-pr.yml +++ b/.github/workflows/build-pr.yml @@ -75,8 +75,7 @@ jobs: git add . git status git commit -m "Build and publish ${{ github.ref }}" - git log --name-status HEAD^..HEAD - git push origin master --dry-run + git push origin master env: GIT_AUTHOR_EMAIL: ${{ github.actor }}@users.noreply.github.com GIT_AUTHOR_NAME: ${{ github.actor }} From 1e24d8abf45369619419268be59161d41426d7dd Mon Sep 17 00:00:00 2001 From: Evan Mattson Date: Sat, 29 Feb 2020 12:44:37 +0200 Subject: [PATCH 22/23] Remove old release script. --- .github/release-to-wiki.sh | 26 -------------------------- 1 file changed, 26 deletions(-) delete mode 100644 .github/release-to-wiki.sh diff --git a/.github/release-to-wiki.sh b/.github/release-to-wiki.sh deleted file mode 100644 index 072b1bc936e..00000000000 --- a/.github/release-to-wiki.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash - -GIT_REPOSITORY_URL="https://${GITHUB_PERSONAL_ACCESS_TOKEN}@github.com/$GITHUB_REPOSITORY.wiki.git" -tmp_dir="/tmp/build/${GIT_REF}" -mkdir -p "$tmp_dir" -( - cd "$tmp_dir" || exit 1 - git clone --depth 1 "$GIT_REPOSITORY_URL" . - git config user.name "$GITHUB_ACTOR" - git config user.email "$GITHUB_ACTOR@users.noreply.github.com" -) - -mkdir -p "$tmp_dir/${GIT_REF}" -ls "${GIT_REF}" -cp "${GIT_REF}/"* "$tmp_dir/${GIT_REF}" - -echo "Publishing build files for ${GIT_REF}" -( - cd "$tmp_dir" || exit 1 - git add . - git commit -m "Build and publish ${GIT_REF}" - git push --set-upstream "$GIT_REPOSITORY_URL" master -) - -rm -rf "$tmp_dir" -exit 0 From 1051d6911994cfc3aa239e1b5d13b368ceeb4cbf Mon Sep 17 00:00:00 2001 From: Evan Mattson Date: Sat, 29 Feb 2020 13:02:06 +0200 Subject: [PATCH 23/23] Refactor remove-pr with checkout action. --- .github/remove-from-wiki.sh | 25 ------------------------- .github/workflows/remove-pr.yml | 21 +++++++++++++++------ 2 files changed, 15 insertions(+), 31 deletions(-) delete mode 100644 .github/remove-from-wiki.sh diff --git a/.github/remove-from-wiki.sh b/.github/remove-from-wiki.sh deleted file mode 100644 index 63a25465c5f..00000000000 --- a/.github/remove-from-wiki.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -GIT_REPOSITORY_URL="https://${GITHUB_PERSONAL_ACCESS_TOKEN}@github.com/$GITHUB_REPOSITORY.wiki.git" - -echo "Checking out wiki repository" -tmp_dir="/tmp/build/${GIT_REF}" -mkdir -p "$tmp_dir" -( - cd "$tmp_dir" || exit 1 - git clone "$GIT_REPOSITORY_URL" . - git config user.name "$GITHUB_ACTOR" - git config user.email "$GITHUB_ACTOR@users.noreply.github.com" -) - -rm -Rf "$tmp_dir/${GIT_REF}" - -echo "Removing build files from ${GIT_REF}" -( - cd "$tmp_dir" || exit 1 - git commit -m "$WIKI_COMMIT_MESSAGE" - git push --set-upstream "$GIT_REPOSITORY_URL" master -) - -rm -rf "$tmp_dir" -exit 0 \ No newline at end of file diff --git a/.github/workflows/remove-pr.yml b/.github/workflows/remove-pr.yml index adc7358159a..9767adc09e4 100644 --- a/.github/workflows/remove-pr.yml +++ b/.github/workflows/remove-pr.yml @@ -7,9 +7,18 @@ jobs: remove-pr: runs-on: ubuntu-latest steps: - - name: Repository Dispatch - run: | - bash .github/remove-from-wiki.sh - env: - GITHUB_PERSONAL_ACCESS_TOKEN: ${{ secrets.GITHUB_PERSONAL_ACCESS_TOKEN }} - GIT_REF: ${{ github.ref }} + - uses: actions/checkout@v2 + with: + repository: ${{ github.repository }}.wiki + - name: Prune PR files + run: | + rm -rf ${{ github.ref }} + git add . + git status + git commit -m "Prune ${{ github.ref }}" + git push origin master + env: + GIT_AUTHOR_EMAIL: ${{ github.actor }}@users.noreply.github.com + GIT_AUTHOR_NAME: ${{ github.actor }} + GIT_COMMITTER_EMAIL: ${{ github.actor }}@users.noreply.github.com + GIT_COMMITTER_NAME: ${{ github.actor }}