-
Notifications
You must be signed in to change notification settings - Fork 2
107 lines (92 loc) · 3.34 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
name: Deployment
on:
push:
tags:
- "v*"
jobs:
deploy:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: ['14.16.x']
env:
CLASP_ACCESS_TOKEN: ${{ secrets.CLASP_ACCESS_TOKEN }}
CLASP_CLIENT_ID: ${{ secrets.CLASP_CLIENT_ID }}
CLASP_CLIENT_SECRET: ${{ secrets.CLASP_CLIENT_SECRET }}
CLASP_EXPIRY_DATE: ${{ secrets.CLASP_EXPIRY_DATE }}
CLASP_ID_TOKEN: ${{ secrets.CLASP_ID_TOKEN }}
CLASP_REFRESH_TOKEN: ${{ secrets.CLASP_REFRESH_TOKEN }}
CLASP_SCRIPT_ID: ${{ secrets.CLASP_SCRIPT_ID }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
- name: Set env
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Cache node modules
uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: ${{ runner.os }}-yarn-
- name: Create authentication file
run: |
echo $(cat <<-EOS
{
"token": {
"access_token": "${CLASP_ACCESS_TOKEN}",
"scope": "https://www.googleapis.com/auth/cloud-platform https://www.googleapis.com/auth/script.webapp.deploy openid 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/logging.read https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/script.deployments https://www.googleapis.com/auth/drive.metadata.readonly",
"token_type": "Bearer",
"id_token": "${CLASP_ID_TOKEN}",
"expiry_date": ${CLASP_EXPIRY_DATE},
"refresh_token": "${CLASP_REFRESH_TOKEN}"
},
"oauth2ClientSettings": {
"clientId": "${CLASP_CLIENT_ID}",
"clientSecret": "${CLASP_CLIENT_SECRET}",
"redirectUri": "http://localhost"
},
"isLocalCreds": false
}
EOS
) > ~/.clasprc.json
- name: Create clasp application file
run: |
echo $(cat <<-EOS
{
"scriptId": "${CLASP_SCRIPT_ID}",
"rootDir": "./src",
"fileExtension": "ts"
}
EOS
) > ./.clasp.json
- name: Get version
id: version
run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/}
- name: Deploy to GAS
run: npx @google/clasp push --force
- name: Add version
run: npx @google/clasp version ${{ steps.version.outputs.VERSION }}
release:
name: Create release note automatically.
runs-on: ubuntu-latest
needs: deploy
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Release
id: release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false