Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fixed workflow_dispatch runs for docker.yml GHA workflow #752

Merged
merged 10 commits into from
Aug 28, 2024
18 changes: 11 additions & 7 deletions .github/workflows/build-and-push-image.yml
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
emaydeck-mozilla marked this conversation as resolved.
Show resolved Hide resolved
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:
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -38,7 +38,7 @@ jobs:

autoconnect:
name: "Autoconnect: Build and push to GAR"
needs: [tag]
needs: [determine-tag]
permissions:
contents: read
id-token: write
Expand All @@ -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
Expand All @@ -62,4 +62,4 @@ jobs:
binary: autoendpoint
crate: autoendpoint
image: autoendpoint
tag: ${{ needs.tag.outputs.TAG }}
tag: ${{ needs.determine-tag.outputs.TAG }}
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down