Skip to content

Commit

Permalink
[.github] - feature: support specifying commit SHA for Docker image t…
Browse files Browse the repository at this point in the history
…ags in build workflow (#10929)

- Introduce commit_sha input in the build-image action to allow image tagging with specific commit SHAs
 - Update deploy workflow to pass the short commit SHA to the build-image action
 - Ensure Docker images are tagged with the correct commit SHA to improve traceability of image versions
  • Loading branch information
JulesBelveze authored Feb 19, 2025
1 parent c6cf967 commit 496bb19
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 5 additions & 2 deletions .github/actions/build-image/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ inputs:
depot_token:
description: "Depot project token"
required: true
commit_sha:
description: "Commit SHA"
required: true

runs:
using: "composite"
Expand Down Expand Up @@ -73,8 +76,8 @@ runs:
--cache-from type=gha,scope=${{ inputs.component }} \
--cache-to type=gha,mode=max,scope=${{ inputs.component }} \
-f ./dockerfiles/${BASE_COMPONENT}.Dockerfile \
-t ${{ inputs.region }}-docker.pkg.dev/${{ inputs.project_id }}/dust-images/${{ inputs.component }}:${GITHUB_SHA::7} \
--build-arg COMMIT_HASH=${GITHUB_SHA::7} \
-t ${{ inputs.region }}-docker.pkg.dev/${{ inputs.project_id }}/dust-images/${{ inputs.component }}:${{ inputs.commit_sha }} \
--build-arg COMMIT_HASH=${{ inputs.commit_sha }} \
${build_args[@]} \
--push \
.
3 changes: 2 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,11 @@ jobs:
uses: ./.github/actions/build-image
with:
project_id: ${{ steps.project.outputs.PROJECT_ID }}
region: ${{ inputs.regions }}
region: ${{ matrix.region }}
component: ${{ inputs.component }}
workload_identity_provider: "projects/357744735673/locations/global/workloadIdentityPools/github-pool-apps/providers/github-provider-apps"
depot_token: ${{ secrets.DEPOT_PROJECT_TOKEN }}
commit_sha: ${{ needs.prepare.outputs.short_sha }}

- name: Notify Failure
if: failure()
Expand Down

0 comments on commit 496bb19

Please sign in to comment.