2525 service_account : artifact-writer@${{ vars.GCP_PROJECT_ID }}.iam.gserviceaccount.com
2626 workload_identity_provider : ${{ vars.GCPV2_GITHUB_WORKLOAD_IDENTITY_PROVIDER }}
2727
28+ - name : Generate versioned tag
29+ id : versioned-tag
30+ run : |
31+ base_tag="${{ github.event.inputs.image_tag }}"
32+ registry="${{ vars.GAR_LOCATION }}-docker.pkg.dev/${{ vars.GCP_PROJECT_ID }}/${{ vars.GAR_REPOSITORY }}"
33+
34+ # Configure gcloud auth using the token
35+ echo "${{ steps.gcp-auth.outputs.access_token }}" | docker login -u oauth2accesstoken --password-stdin ${{ vars.GAR_LOCATION }}-docker.pkg.dev
36+
37+ # Find the highest version number for this base tag
38+ version_number=1
39+ while true; do
40+ versioned_tag="${base_tag}-${version_number}"
41+
42+ # Check if image exists in registry
43+ if gcloud container images describe "${registry}/bugbug-http-service:${versioned_tag}" --quiet >/dev/null 2>&1; then
44+ version_number=$((version_number + 1))
45+ else
46+ break
47+ fi
48+ done
49+
50+ echo "versioned_tag=$versioned_tag" >> $GITHUB_OUTPUT
51+
2852 - name : Pull web image
2953 run : docker pull mozilla/bugbug-http-service:${{ github.event.inputs.image_tag }}
3054
@@ -39,13 +63,13 @@ jobs:
3963 password : ${{ steps.gcp-auth.outputs.access_token }}
4064
4165 - name : Tag web image
42- run : docker tag mozilla/bugbug-http-service:${{ github.event.inputs.image_tag }} ${{ vars.GAR_LOCATION }}-docker.pkg.dev/${{ vars.GCP_PROJECT_ID }}/${{ vars.GAR_REPOSITORY }}/bugbug-http-service:${{ github.event.inputs.image_tag }}
66+ run : docker tag mozilla/bugbug-http-service:${{ github.event.inputs.image_tag }} ${{ vars.GAR_LOCATION }}-docker.pkg.dev/${{ vars.GCP_PROJECT_ID }}/${{ vars.GAR_REPOSITORY }}/bugbug-http-service:${{ steps.versioned-tag.outputs.versioned_tag }}
4367
4468 - name : Push web image
45- run : docker push ${{ vars.GAR_LOCATION }}-docker.pkg.dev/${{ vars.GCP_PROJECT_ID }}/${{ vars.GAR_REPOSITORY }}/bugbug-http-service:${{ github.event.inputs.image_tag }}
69+ run : docker push ${{ vars.GAR_LOCATION }}-docker.pkg.dev/${{ vars.GCP_PROJECT_ID }}/${{ vars.GAR_REPOSITORY }}/bugbug-http-service:${{ steps.versioned-tag.outputs.versioned_tag }}
4670
4771 - name : Tag worker image
48- run : docker tag mozilla/bugbug-http-service-bg-worker:${{ github.event.inputs.image_tag }} ${{ vars.GAR_LOCATION }}-docker.pkg.dev/${{ vars.GCP_PROJECT_ID }}/${{ vars.GAR_REPOSITORY }}/bugbug-http-service-bg-worker:${{ github.event.inputs.image_tag }}
72+ run : docker tag mozilla/bugbug-http-service-bg-worker:${{ github.event.inputs.image_tag }} ${{ vars.GAR_LOCATION }}-docker.pkg.dev/${{ vars.GCP_PROJECT_ID }}/${{ vars.GAR_REPOSITORY }}/bugbug-http-service-bg-worker:${{ steps.versioned-tag.outputs.versioned_tag }}
4973
5074 - name : Push worker image
51- run : docker push ${{ vars.GAR_LOCATION }}-docker.pkg.dev/${{ vars.GCP_PROJECT_ID }}/${{ vars.GAR_REPOSITORY }}/bugbug-http-service-bg-worker:${{ github.event.inputs.image_tag }}
75+ run : docker push ${{ vars.GAR_LOCATION }}-docker.pkg.dev/${{ vars.GCP_PROJECT_ID }}/${{ vars.GAR_REPOSITORY }}/bugbug-http-service-bg-worker:${{ steps.versioned-tag.outputs.versioned_tag }}
0 commit comments