Skip to content

20230921

20230921 #118

Workflow file for this run

name: Node.js CI
on:
workflow_dispatch:
pull_request:
push:
branches: [ master ]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: 安裝 Node.js 與 yarn
uses: actions/setup-node@v3
with:
node-version: 20
cache: 'yarn'
- name: install, lint, test
run: |
yarn
yarn lint
yarn test
deploy:
if: github.ref == 'refs/heads/master'
needs: test
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/checkout@v3
- name: 安裝 Node.js 與 yarn
uses: actions/setup-node@v3
with:
node-version: 20
cache: 'yarn'
- id: 'auth'
uses: google-github-actions/auth@v0
with:
workload_identity_provider: 'projects/391399927959/locations/global/workloadIdentityPools/github-actions-taichunmin-pools/providers/github-actions-provider'
service_account: '[email protected]'
# https://github.com/google-github-actions/setup-gcloud
# https://github.com/google-github-actions/auth#setting-up-workload-identity-federation
- name: 設定 Google Cloud SDK
uses: google-github-actions/setup-gcloud@v0
- name: 確認 Google Cloud SDK
run: gcloud info
- name: 建立 GCF 環境變數檔案
shell: bash
run: |
[[ -z "$ENV_PROD" ]] || echo "$ENV_PROD" > .env.yaml
echo "GITHUB_SHA: ${GITHUB_SHA}" >> .env.yaml
env:
ENV_PROD: ${{ secrets.ENV_PROD }}
- name: 部署到 Google Cloud Functions
run: yarn deploy