-
Notifications
You must be signed in to change notification settings - Fork 2
69 lines (55 loc) · 2.02 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
59
60
61
62
63
64
65
66
67
68
name: NodeJs GCP Artifact Registry CI
on:
push:
branches: [ "main" ]
env:
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
GCP_PROJECT_NUMBER: ${{ secrets.GCP_PROJECT_NUMBER }}
GCP_REGION: us-east4
GCP_REPSOSIROTY: emp-mng-system
GCP_APPLICATION_NAME: employee-management-api
jobs:
build-test-and-push:
runs-on: ubuntu-latest
permissions:
contents: 'read'
id-token: 'write'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up node.js
uses: actions/[email protected]
with:
node-version: '20.10'
cache: 'npm'
- name: Install dependencies
run: |
npm install
- name: Build
run: |
npm run build --if-present
- name: IT Test
run: |
npm run test --if-present
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v1
- name: Build Container
run: |-
docker build -t "${{ env.GCP_REGION }}-docker.pkg.dev/${{ env.GCP_PROJECT_ID }}/${{ env.GCP_REPSOSIROTY }}/${{ env.GCP_APPLICATION_NAME }}:latest" .
- id: 'auth'
name: 'Authenticate to Google Cloud'
uses: 'google-github-actions/auth@v1'
with:
token_format: access_token
workload_identity_provider: 'projects/${{ env.GCP_PROJECT_NUMBER }}/locations/global/workloadIdentityPools/backend-gh-wif-pool/providers/backend-gh-wif-provider'
service_account: 'github-actions-ar-sa@${{ env.GCP_PROJECT_ID }}.iam.gserviceaccount.com'
- name: Authenticate Docker to Google Cloud Artifact Registry
id: docker-auth
uses: 'docker/login-action@v3'
with:
registry: ${{ env.GCP_REGION }}-docker.pkg.dev
username: oauth2accesstoken
password: ${{ steps.auth.outputs.access_token }}
- name: Push Container
run: |-
docker push "${{ env.GCP_REGION }}-docker.pkg.dev/${{ env.GCP_PROJECT_ID }}/${{ env.GCP_REPSOSIROTY }}/${{ env.GCP_APPLICATION_NAME }}:latest"