-
Notifications
You must be signed in to change notification settings - Fork 10
80 lines (69 loc) · 2.89 KB
/
deploy.yml
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
name: Deploy
on:
push:
tags:
- 'v*'
jobs:
release:
runs-on: ubuntu-latest
env:
RELEASE_CLASPRC_ACCESS_TOKEN: ${{ secrets.RELEASE_CLASPRC_ACCESS_TOKEN }}
RELEASE_CLASPRC_CLIENT_ID: ${{ secrets.RELEASE_CLASPRC_CLIENT_ID }}
RELEASE_CLASPRC_CLIENT_SECRET: ${{ secrets.RELEASE_CLASPRC_CLIENT_SECRET }}
RELEASE_CLASPRC_EXPIRY_DATE: ${{ secrets.RELEASE_CLASPRC_EXPIRY_DATE }}
RELEASE_CLASPRC_ID_TOKEN: ${{ secrets.RELEASE_CLASPRC_ID_TOKEN }}
RELEASE_CLASPRC_REFRESH_TOKEN: ${{ secrets.RELEASE_CLASPRC_REFRESH_TOKEN }}
RELEASE_CLASP_SCRIPT_ID: ${{ secrets.RELEASE_CLASP_SCRIPT_ID }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22'
- name: Cache node modules
uses: actions/[email protected]
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Create ~/.clasprc.json
run: |
echo $(cat <<-EOS
{
"token": {
"access_token": "${RELEASE_CLASPRC_ACCESS_TOKEN}",
"scope": "https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/script.projects https://www.googleapis.com/auth/drive.file https://www.googleapis.com/auth/service.management https://www.googleapis.com/auth/cloud-platform https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/script.webapp.deploy openid https://www.googleapis.com/auth/script.deployments https://www.googleapis.com/auth/logging.read https://www.googleapis.com/auth/drive.metadata.readonly",
"token_type": "Bearer",
"id_token": "${RELEASE_CLASPRC_ID_TOKEN}",
"expiry_date": ${RELEASE_CLASPRC_EXPIRY_DATE},
"refresh_token": "${RELEASE_CLASPRC_REFRESH_TOKEN}"
},
"oauth2ClientSettings": {
"clientId": "${RELEASE_CLASPRC_CLIENT_ID}",
"clientSecret": "${RELEASE_CLASPRC_CLIENT_SECRET}",
"redirectUri": "http://localhost"
},
"isLocalCreds": false
}
EOS
) > ~/.clasprc.json
- name: Create ~/.clasp.json
run: |
echo $(cat <<-EOS
{
"scriptId": "${RELEASE_CLASP_SCRIPT_ID}",
"rootDir": "./src"
}
EOS
) > ./.clasp.json
- name: Get version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/}
- name: Upload files
run: npx @google/clasp push --force
- name: Deploy
run: npx @google/clasp deploy -d ${{ steps.get_version.outputs.VERSION }}