diff --git a/.github/workflows/build-and-push-image.yml b/.github/workflows/build-and-push-image.yml index 96e61249b..39fe3a916 100644 --- a/.github/workflows/build-and-push-image.yml +++ b/.github/workflows/build-and-push-image.yml @@ -1,4 +1,4 @@ -name: Build and push image to GAR +name: Reusable build-and-push workflow run-name: Build and push image "${{ inputs.image }}:${{ inputs.tag }}" to GAR @@ -11,16 +11,20 @@ on: crate: required: true type: string + # `gar_location`, `gar_repository`, and `gcp_project_id` have all been + # set as optional because default value has been supplied. As this + # workflow is only callable by other workflows, GitHub Actions will throw + # an error if we set "required: true" regardless of any defaults defined. gar_location: - required: true + required: false type: string default: us gar_repository: - required: true + required: false type: string default: autopush-prod gcp_project_id: - required: true + required: false type: string default: moz-fx-autopush-prod image: @@ -57,6 +61,7 @@ jobs: "${GITHUB_SERVER_URL}" \ "${GITHUB_REPOSITORY}" \ "${GITHUB_RUN_ID}" > version.json + - uses: docker/setup-buildx-action@v3 - id: gcp-auth uses: google-github-actions/auth@v2 with: @@ -73,9 +78,8 @@ jobs: with: context: . file: Dockerfile - tags: - - ${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.GCP_PROJECT_ID }}/${{ env.GAR_REPOSITORY }}/${{ env.IMAGE }}:latest - - ${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.GCP_PROJECT_ID }}/${{ env.GAR_REPOSITORY }}/${{ env.IMAGE }}:${{ env.TAG }} + # This is using both "latest" and app version tags. + tags: ${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.GCP_PROJECT_ID }}/${{ env.GAR_REPOSITORY }}/${{ env.IMAGE }}:latest,${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.GCP_PROJECT_ID }}/${{ env.GAR_REPOSITORY }}/${{ env.IMAGE }}:${{ env.TAG }} push: true cache-from: type=gha cache-to: type=gha,mode=max diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 383a1af31..460feb5cc 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -12,11 +12,11 @@ jobs: determine-tag: name: Determine tag to build if: | - github.event_name == "workflow_dispatch" || - (github.event_name == "check_run" && \ - github.event.check_run.name == "build-test-deploy" && \ - github.event.check_run.conclusion == "success" && \ - github.ref_type == "tag") + github.event_name == 'workflow_dispatch' || + (github.event_name == 'check_run' && + github.event.check_run.name == 'build-test-deploy' && + github.event.check_run.conclusion == 'success' && + github.ref_type == 'tag') runs-on: ubuntu-latest permissions: {} outputs: @@ -38,7 +38,7 @@ jobs: autoconnect: name: "Autoconnect: Build and push to GAR" - needs: [tag] + needs: [determine-tag] permissions: contents: read id-token: write @@ -48,11 +48,11 @@ jobs: binary: autoconnect crate: autoconnect image: autoconnect - tag: ${{ needs.tag.outputs.TAG }} + tag: ${{ needs.determine-tag.outputs.TAG }} autoendpoint: name: "Autoendpoint: Build and push to GAR" - needs: [tag] + needs: [determine-tag] permissions: contents: read id-token: write @@ -62,4 +62,4 @@ jobs: binary: autoendpoint crate: autoendpoint image: autoendpoint - tag: ${{ needs.tag.outputs.TAG }} + tag: ${{ needs.determine-tag.outputs.TAG }} diff --git a/Dockerfile b/Dockerfile index ab2d396c8..55264aa5c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ # NOTE: Ensure builder's Rust version matches CI's in .circleci/config.yml # RUST_VER -FROM rust:1.80-bookworm as builder +FROM rust:1.80-bookworm AS builder ARG CRATE ADD . /app