From 631cd8ecbbf079d64d8ef3eb4e8cc6b689c5beac Mon Sep 17 00:00:00 2001 From: Steven Bazyl Date: Mon, 1 Aug 2022 19:38:21 -0600 Subject: [PATCH 1/3] chore: Enable release-please workflows & deployment with clasp --- .clasp.json | 6 ++++++ .github/workflows/release-please.yml | 30 ++++++++++++++++++++++++++++ .github/workflows/update-dist.yml | 27 +++++++++++++++++++++++++ src/appsscript.json | 11 ++++++++++ 4 files changed, 74 insertions(+) create mode 100644 .clasp.json create mode 100644 .github/workflows/release-please.yml create mode 100644 .github/workflows/update-dist.yml create mode 100644 src/appsscript.json diff --git a/.clasp.json b/.clasp.json new file mode 100644 index 0000000..fa4c89a --- /dev/null +++ b/.clasp.json @@ -0,0 +1,6 @@ +{ + "scriptId": "1CXDCY5sqT9ph64fFwSzVtXnbjpSfWdRymafDrtIZ7Z_hwysTY7IIhi7s", + "rootDir": "src/", + "fileExtension": "gs" +} + diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml new file mode 100644 index 0000000..27aa223 --- /dev/null +++ b/.github/workflows/release-please.yml @@ -0,0 +1,30 @@ +on: + push: + branches: + - main +name: release-please +jobs: + release-please: + runs-on: ubuntu-latest + steps: + - uses: google-github-actions/release-please-action@v3 + with: + release-type: node + package-name: release-please-action + - uses: actions/checkout@v2 + if: ${{ steps.release.outputs.pr }} + - uses: actions/setup-node@v1 + if: ${{ steps.release.outputs.release_created }} + with: + node-version: 16 + - name: Write test credentials + if: ${{ steps.release.outputs.release_created }} + run: | + echo "${CLASP_CREDENTIALS}" > "${HOME}/.clasprc.json" + env: + CLASP_CREDENTIALS: ${{secrets.LIBRARIES_OWNER_CLASP_TOKEN}} + - name: Depoy scripts + if: ${{ steps.release.outputs.release_created }} + run: | + npx @google/clasp push + npx @google/clasp version diff --git a/.github/workflows/update-dist.yml b/.github/workflows/update-dist.yml new file mode 100644 index 0000000..f3a8aae --- /dev/null +++ b/.github/workflows/update-dist.yml @@ -0,0 +1,27 @@ +on: [pull_request] +name: Update dist folder +jobs: + update-dist-src: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + ref: ${{ github.event.pull_request.head.ref }} + - uses: actions/setup-node@v1 + with: + node-version: 16 + - name: Install dependencies + run: npm ci + - name: Generate dist + run: npm run dist + - name: Check for modified files + id: git-check + run: echo ::set-output name=modified::$(if git diff-index --quiet HEAD --; then echo "false"; else echo "true"; fi) + - name: Push changes + if: steps.git-check.outputs.modified == 'true' + run: | + git config --global user.name 'Google Workspace Bot' + git config --global user.email 'googleworkspace-bot@google.com' + git remote set-url origin https://x-access-token:${{ secrets.GOOGLEWORKSPACE_BOT_TOKEN }}@github.com/${{ github.repository }} + git commit -am "chore: Update dist/ directory" + git push diff --git a/src/appsscript.json b/src/appsscript.json new file mode 100644 index 0000000..01635b6 --- /dev/null +++ b/src/appsscript.json @@ -0,0 +1,11 @@ +{ + "timeZone": "America/New_York", + "dependencies": { + "libraries": [{ + "userSymbol": "Underscore", + "libraryId": "1I21uLOwDKdyF3_W_hvh6WXiIKWJWno8yG9lB8lf1VBnZFQ6jAAhyNTRG", + "version": "24" + }] + }, + "exceptionLogging": "STACKDRIVER" +} From 076d61892e39852bf3ba1c3761d3d8c4e4e665d8 Mon Sep 17 00:00:00 2001 From: Steve Bazyl Date: Tue, 2 Aug 2022 14:07:18 -0600 Subject: [PATCH 2/3] chore: Move token + guard action Moves the token setup to actions/checkout + guards the workflow so dist files are only updated as part of release PRs. --- .github/workflows/update-dist.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/update-dist.yml b/.github/workflows/update-dist.yml index f3a8aae..6d49a1e 100644 --- a/.github/workflows/update-dist.yml +++ b/.github/workflows/update-dist.yml @@ -2,11 +2,13 @@ on: [pull_request] name: Update dist folder jobs: update-dist-src: + if: contains(github.event.pull_request.labels.*.name, 'autorelease: pending') runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 with: ref: ${{ github.event.pull_request.head.ref }} + token: ${{ secrets.GOOGLEWORKSPACE_BOT_TOKEN }} - uses: actions/setup-node@v1 with: node-version: 16 @@ -22,6 +24,5 @@ jobs: run: | git config --global user.name 'Google Workspace Bot' git config --global user.email 'googleworkspace-bot@google.com' - git remote set-url origin https://x-access-token:${{ secrets.GOOGLEWORKSPACE_BOT_TOKEN }}@github.com/${{ github.repository }} git commit -am "chore: Update dist/ directory" git push From 9f11dead030fb717d4b72a569c69e27383eef9b8 Mon Sep 17 00:00:00 2001 From: Steve Bazyl Date: Tue, 2 Aug 2022 14:19:04 -0600 Subject: [PATCH 3/3] fix: Tweak syntax for yml parsing --- .github/workflows/update-dist.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/update-dist.yml b/.github/workflows/update-dist.yml index 6d49a1e..2257a91 100644 --- a/.github/workflows/update-dist.yml +++ b/.github/workflows/update-dist.yml @@ -2,7 +2,8 @@ on: [pull_request] name: Update dist folder jobs: update-dist-src: - if: contains(github.event.pull_request.labels.*.name, 'autorelease: pending') + if: | + ${{ contains(github.event.pull_request.labels.*.name, "autorelease: pending") }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v2