-
Notifications
You must be signed in to change notification settings - Fork 0
63 lines (61 loc) · 2.05 KB
/
deploy.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
name: Deploy
on:
push:
branches:
- main
workflow_dispatch:
jobs:
deploy:
name: deploy to staging
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/[email protected]
with:
version: latest
- name: Setup Node.js environment
uses: actions/[email protected]
- name: Log into Google
run: echo "$AUTH_CREDENTIALS" > $HOME/.clasprc.json
env:
AUTH_CREDENTIALS: ${{ secrets.AUTH_CREDENTIALS }}
- name: Set up clasp
run: |
echo "{\"scriptId\":\"$SCRIPT_ID\",\"rootDir\":\"$GITHUB_WORKSPACE\"}" > $GITHUB_WORKSPACE/.clasp.json
env:
SCRIPT_ID: ${{ secrets.SCRIPT_ID }}
- name: Install dependencies
run: pnpm install
- name: Build
run: pnpm run build
- name: Calculate hash of current build
run: tar -cf - ./build | sha256sum | cut -d' ' -f1 > ./build/.build_hash.current
- name: Cache build hash
uses: actions/cache@v3
with:
path: build/.build_hash
key: ${{ runner.os }}-build-${{ github.sha }}
restore-keys: |
${{ runner.os }}-build-
- name: Check if build output changed
id: check_diff
continue-on-error: true
run: |
diff -q build/.build_hash build/.build_hash.current && echo "No changes in build output" && exit 0 || echo "Build output changed" && exit 1
- name: Update build hash
if: ${{ steps.check_diff.outcome == 'failure'}}
run: cp build/.build_hash.current build/.build_hash
- name: Push
if: ${{ steps.check_diff.outcome == 'failure'}}
run: pnpm run push
- name: Deploy new version
if: ${{ steps.check_diff.outcome == 'failure'}}
run: |
echo "::add-mask::$DEPLOY_ID"
pnpm clasp deploy --deploymentId $DEPLOY_ID
env:
DEPLOY_ID: ${{ secrets.DEPLOY_ID }}
- name: Clean up credentials
if: ${{ always() }}
run: rm -f $HOME/.clasprc.json