From 1748d4579aa89bc39ea8670253dbe94d6291a427 Mon Sep 17 00:00:00 2001 From: Jon Buckley Date: Sat, 12 Oct 2024 14:21:24 -0400 Subject: [PATCH] fix(docker): Use git tag from lookup The `GITHUB_REF_NAME` variable only works for tags pushed by developers. When calling the docker.yml workflow from tag-release.yml, the contents of `GITHUB_REF_NAME` is `main`, the branch that the GitHub Action is running on. This will fix the version output for x.y.0 tags created by tag-release.yml. --- .github/workflows/docker.yml | 6 +++--- _scripts/create-version-json.sh | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 8d39827097..8bdc3843ac 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -49,13 +49,13 @@ jobs: GCP_PROJECT_ID: moz-fx-fxa-prod IMAGE: fxa-mono RUN_ID: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} - TAG: ${{ needs.tag.outputs.TAG }} + GIT_TAG: ${{ needs.tag.outputs.TAG }} needs: - tag steps: - uses: actions/checkout@v4 with: - ref: ${{ env.TAG }} + ref: ${{ env.GIT_TAG }} - uses: actions/setup-node@v4 with: @@ -87,7 +87,7 @@ jobs: with: context: . file: _dev/docker/mono/Dockerfile - tags: ${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.GCP_PROJECT_ID }}/${{ env.GAR_REPOSITORY}}/${{ env.IMAGE}}:${{ env.TAG }} + tags: ${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.GCP_PROJECT_ID }}/${{ env.GAR_REPOSITORY}}/${{ env.IMAGE}}:${{ env.GIT_TAG }} push: true cache-from: type=gha cache-to: type=gha,mode=max diff --git a/_scripts/create-version-json.sh b/_scripts/create-version-json.sh index 0db39465d6..def28dbbac 100755 --- a/_scripts/create-version-json.sh +++ b/_scripts/create-version-json.sh @@ -13,7 +13,7 @@ if [[ "${CIRCLECI}" == "true" ]]; then elif [[ "${GITHUB_ACTIONS}" == "true" ]]; then printf '{"version":{"hash":"%s","version":"%s","source":"https://github.com/%s","build":"%s/%s/actions/runs/%s"}}\n' \ "${GITHUB_SHA}" \ - "${GITHUB_REF_NAME}" \ + "${GIT_TAG}" \ "${GITHUB_REPOSITORY}" \ "${GITHUB_SERVER_URL}" \ "${GITHUB_REPOSITORY}" \