@@ -51,33 +51,39 @@ permissions:
5151jobs :
5252 deploy :
5353 runs-on : ubuntu-latest
54+
5455 steps :
5556 - name : Checkout Repository
5657 uses : actions/checkout@v4
57-
58+
59+ # Authenticate to Google Cloud using Workload Identity
5860 - name : Authenticate to Google Cloud
5961 id : auth
6062 uses : google-github-actions/auth@v2
6163 with :
6264 workload_identity_provider : projects/${{ inputs.project_number }}/locations/global/workloadIdentityPools/orsp-dev-workloadpool/providers/github
6365 service_account : ${{ inputs.service_account }}
64-
65- - name : Setup Gcloud
66+ token_format : access_token
67+
68+ - name : Setup gcloud
6669 uses : google-github-actions/setup-gcloud@v2
6770
71+ # Login to Artifact Registry
6872 - name : Docker Login
6973 uses : docker/login-action@v3
7074 with :
7175 registry : ${{ inputs.registry_region }}-docker.pkg.dev
7276 username : oauth2accesstoken
7377 password : ${{ steps.auth.outputs.access_token }}
7478
75- - name : Extract Tag
79+ # Generate image tag using commit SHA
80+ - name : Generate Image Tag
7681 run : |
77- TAG=${GITHUB_REF#refs/tags/}
78- echo "IMAGE_URI=${{ inputs.registry_region }}-docker.pkg.dev/${{ inputs.project_id }}/${{ inputs.artifact_registry }}/${{ inputs.image }}:$TAG" >> $GITHUB_ENV
82+ TAG=${GITHUB_SHA::7}
83+ IMAGE_URI=${{ inputs.registry_region }}-docker.pkg.dev/${{ inputs.project_id }}/${{ inputs.artifact_registry }}/${{ inputs.image }}:$TAG
84+ echo "IMAGE_URI=$IMAGE_URI" >> $GITHUB_ENV
7985
80- - name : Set up Docker Buildx
86+ - name : Setup Docker Buildx
8187 uses : docker/setup-buildx-action@v3
8288
8389 - name : Build and Push Docker Image
@@ -89,12 +95,14 @@ jobs:
8995 cache-from : type=gha
9096 cache-to : type=gha,mode=max
9197
98+ # Get credentials for GKE
9299 - name : Get GKE Credentials
93100 uses : google-github-actions/get-gke-credentials@v2
94101 with :
95102 cluster_name : ${{ inputs.cluster }}
96103 location : ${{ inputs.cluster_region }}
97104
105+ # Deploy to Kubernetes
98106 - name : Deploy to Kubernetes
99107 run : |
100108 set -e
0 commit comments