-
Notifications
You must be signed in to change notification settings - Fork 0
71 lines (58 loc) · 1.85 KB
/
app-gcp-api-CI.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
name: api-CI
on:
workflow_dispatch:
pull_request:
paths: 'api/**'
jobs:
api-CI:
name: api-CI
permissions:
contents: 'read'
id-token: 'write'
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./api/
strategy:
matrix:
node-version: [18.x]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache-dependency-path: api/package-lock.json
- name: install dependency
run: npm ci
- name: build api-bundled
run: npm run build api-bundled
- name: run test
run: npm test
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Google Auth
id: auth
uses: 'google-github-actions/auth@v0'
with:
token_format: 'access_token'
workload_identity_provider: '${{ secrets.WIF_PROVIDER }}' # e.g. - projects/123456789/locations/global/workloadIdentityPools/my-pool/providers/my-provider
service_account: '${{ secrets.WIF_SERVICE_ACCOUNT }}' # e.g. - [email protected]
# Authenticate Docker to Google Cloud Artifact Registry
- name: Docker Auth
id: docker-auth
uses: 'docker/login-action@v1'
with:
username: 'oauth2accesstoken'
password: '${{ steps.auth.outputs.access_token }}'
registry: '${{ secrets.GAR_LOCATION }}-docker.pkg.dev'
- name: Build and push
uses: docker/build-push-action@v4
with:
context: './api'
push: true
tags: '${{ secrets.DOCKER_IMAGE_API_TAG }}'
cache-from: type=gha
cache-to: type=gha,mode=max