Skip to content

Commit

Permalink
Merge pull request #4 from mikedownesdev/develop
Browse files Browse the repository at this point in the history
Prod deploy script
  • Loading branch information
mikedownesdev authored Sep 6, 2023
2 parents 8c5c780 + 35434d9 commit 6d1cb7e
Showing 1 changed file with 74 additions and 0 deletions.
74 changes: 74 additions & 0 deletions .github/workflows/prod-env-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Prod Env Deploy Script

on:
workflow_dispatch:
push:
branches: [main]

jobs:
build_and_deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Setup Node
uses: actions/setup-node@v3

- name: Install dependencies
uses: bahmutov/npm-install@v1

- name: Install clasp
id: install-clasp
run: sudo npm install @google/clasp@2.4.1 -g

- name: Write CLASPRC_JSON secret to .clasprc.json file
id: write-clasprc
run: echo "$CLASPRC_JSON_SECRET" >> ~/.clasprc.json
env:
CLASPRC_JSON_SECRET: ${{ secrets.CLASPRC_JSON }}

- name: Check clasp login status
id: clasp_login
run: clasp login --status

- name: Save current .clasprc.json contents to CLASPRC_JSON_FILE environment variable
id: save-clasprc
run: |
echo ::add-mask::$(tr -d '\n\r' < ~/.clasprc.json)
echo "CLASPRC_JSON_FILE=$(tr -d '\n\r' < ~/.clasprc.json)" >> $GITHUB_ENV
- name: Save CLASPRC_JSON_FILE environment variable to CLASPRC_JSON repo secret
id: set-clasprc-secret
if: ${{ env.CLASPRC_JSON_FILE != env.CLASPRC_JSON_SECRET }}
uses: hmanzur/actions-set-secret@v2.0.0
env:
CLASPRC_JSON_SECRET: ${{ secrets.CLASPRC_JSON }}
with:
name: "CLASPRC_JSON"
value: ${{ env.CLASPRC_JSON_FILE }}
repository: ${{ github.repository }}
token: ${{ secrets.REPO_ACCESS_TOKEN }}

- name: Set scriptId in .clasp.json file
id: set-script-id
run: jq '.scriptId = "${{env.PROD_SCRIPT_ID}}"' .clasp.json > /tmp/.clasp.json && mv /tmp/.clasp.json .clasp.json
env:
TEST_SCRIPT_ID: ${{secrets.PROD_SCRIPT_ID}}

## Build & push

- name: Build project
run: npm run build

- name: Push script to scripts.google.com
id: clasp-push
run: clasp push -f

- name: Deploy Script
id: clasp-deploy
if: github.ref == 'refs/heads/test'
run: clasp deploy -i "${{ secrets.PROD_DEPLOYMENT_ID }}" -d ${{github.run_number}}
env:
TEST_SCRIPT_ID: ${{ secrets.PROD_SCRIPT_ID }}

0 comments on commit 6d1cb7e

Please sign in to comment.