-
Notifications
You must be signed in to change notification settings - Fork 0
50 lines (42 loc) · 1.43 KB
/
build-push-gcp.yaml
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
# Workflow configuration that builds and pushes Docker image to GCP
name: Build and Push to GCP
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
env:
PROJECT_ID: trainer-gketraining21
GAR_LOCATION: asia-south1
REPOSITORY: order-microservice-repo
IMAGE_NAME: order-microservice
permissions:
contents: read
id-token: write
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Google Auth
id: auth
uses: google-github-actions/auth@v2
with:
workload_identity_provider: 'projects/381882042224/locations/global/workloadIdentityPools/github-pool-new/providers/github-provider'
service_account: '[email protected]'
- name: Docker Auth
id: docker-auth
uses: docker/login-action@v3
with:
registry: ${{ env.GAR_LOCATION }}-docker.pkg.dev
username: oauth2accesstoken
password: ${{ steps.auth.outputs.access_token }}
- name: Build and Push Container
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: |
${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.IMAGE_NAME }}:latest