Skip to content

Commit

Permalink
Update build-push-gcp.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
pradeepkl authored Dec 1, 2024
1 parent 4ff5ea2 commit a61f2b4
Showing 1 changed file with 37 additions and 38 deletions.
75 changes: 37 additions & 38 deletions .github/workflows/build-push-gcp.yaml
Original file line number Diff line number Diff line change
@@ -1,50 +1,49 @@
# Workflow configuration that builds and pushes Docker image to GCP
name: Build and Push to GCP

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

env:
PROJECT_ID: trainer-gketraining21
GAR_LOCATION: asia-south1
REPOSITORY: order-microservice-repo
IMAGE_NAME: order-microservice
PROJECT_ID: trainer-gketraining21
GAR_LOCATION: asia-south1
REPOSITORY: order-microservice-repo
IMAGE_NAME: order-microservice

permissions:
contents: read
id-token: write
contents: read
id-token: write

jobs:
build-and-push:
runs-on: ubuntu-latest
build-and-push:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
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: 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
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: 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
- 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

0 comments on commit a61f2b4

Please sign in to comment.