-
Notifications
You must be signed in to change notification settings - Fork 8
58 lines (54 loc) · 1.61 KB
/
main.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
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