Skip to content

Update build-and-push.yml #10

Update build-and-push.yml

Update build-and-push.yml #10

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]'
token_format: 'access_token'
- name: 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