Skip to content

20240314

20240314 #127

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@v4
- name: 安裝 Node.js 與 yarn
uses: actions/setup-node@v4
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@v4
- name: 安裝 Node.js 與 yarn
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'yarn'
# https://github.com/google-github-actions/auth#setting-up-workload-identity-federation
- id: 'auth'
uses: google-github-actions/auth@v2
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
- name: 設定 Google Cloud SDK
uses: google-github-actions/setup-gcloud@v2
- 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