Skip to content

Commit

Permalink
Merge pull request #10 from ttsukagoshi/add-release-workflow
Browse files Browse the repository at this point in the history
Create deployment workflow on GitHub Actions
  • Loading branch information
ttsukagoshi authored May 6, 2022
2 parents 1b4a362 + 9ff7a66 commit ab24edc
Showing 1 changed file with 80 additions and 0 deletions.
80 changes: 80 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Deploy

on:
push:
tags:
- 'v*'

jobs:
release:
runs-on: ubuntu-latest

env:
CLASPRC_ACCESS_TOKEN: ${{ secrets.CLASPRC_ACCESS_TOKEN }}
CLASPRC_CLIENT_ID: ${{ secrets.CLASPRC_CLIENT_ID }}
CLASPRC_CLIENT_SECRET: ${{ secrets.CLASPRC_CLIENT_SECRET }}
CLASPRC_EXPIRY_DATE: ${{ secrets.CLASPRC_EXPIRY_DATE }}
CLASPRC_ID_TOKEN: ${{ secrets.CLASPRC_ID_TOKEN }}
CLASPRC_REFRESH_TOKEN: ${{ secrets.CLASPRC_REFRESH_TOKEN }}
CLASP_SCRIPT_ID: ${{ secrets.CLASP_SCRIPT_ID }}

steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: '16'

- name: Cache node modules
uses: actions/cache@v3.0.2
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": "${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": "${CLASPRC_ID_TOKEN}",
"expiry_date": ${CLASPRC_EXPIRY_DATE},
"refresh_token": "${CLASPRC_REFRESH_TOKEN}"
},
"oauth2ClientSettings": {
"clientId": "${CLASPRC_CLIENT_ID}",
"clientSecret": "${CLASPRC_CLIENT_SECRET}",
"redirectUri": "http://localhost"
},
"isLocalCreds": false
}
EOS
) > ~/.clasprc.json
- name: Create ~/.clasp.json
run: |
echo $(cat <<-EOS
{
"scriptId": "${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 }}

0 comments on commit ab24edc

Please sign in to comment.