Skip to content

Commit

Permalink
fix: fixed workflow_dispatch runs for docker.yml GHA workflow (#752)
Browse files Browse the repository at this point in the history
This includes fixes for the GHA workflow that builds and pushes images
to GAR.
  • Loading branch information
emaydeck-mozilla authored Aug 28, 2024
1 parent 4d1f7e9 commit 2acc581
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 17 deletions.
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
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

Check warning on line 3 in Dockerfile

View workflow job for this annotation

GitHub Actions / Autoconnect: Build and push to GAR / build-and-push

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/

Check warning on line 3 in Dockerfile

View workflow job for this annotation

GitHub Actions / Autoendpoint: Build and push to GAR / build-and-push

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/
ARG CRATE

ADD . /app
Expand Down

0 comments on commit 2acc581

Please sign in to comment.