Skip to content

Commit

Permalink
chore: prefer git tag for docker image tag (#768)
Browse files Browse the repository at this point in the history
We should prefer to use a tag for images over the default branch when
applicable.

Also, since we're filtering by the default branch in the workflow, we
don't need to validate the branch name in the job.
  • Loading branch information
emaydeck-mozilla authored Sep 23, 2024
1 parent b525601 commit 9afbe42
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -382,13 +382,19 @@ jobs:
- run:
name: Restore Docker image cache
command: docker load -i /tmp/cache/docker.tar
# This is the easiest way to tag multiple images using different
# conditions for the GAR_TAG variable in the smallest amount of code.
#
# You can find other jobs and commands you can use with this orb that
# include tagging here:
# https://circleci.com/developer/orbs/orb/circleci/gcp-gcr
- run:
name: Tag image
command: |
if [ "${CIRCLE_BRANCH}" == "master" ]; then
echo 'export GAR_TAG=master' >> $BASH_ENV
elif [ ! -z "${CIRCLE_TAG}" ]; then
echo "export GAR_TAG=$CIRCLE_TAG" >> $BASH_ENV
if [ ! -z "${CIRCLE_TAG}" ]; then
echo "export GAR_TAG=${CIRCLE_TAG}" >> $BASH_ENV
else
echo "export GAR_TAG=${CIRCLE_BRANCH}" >> $BASH_ENV
fi
echo "export GAR_IMAGE=\"<<parameters.registry-url>>/${GCP_GAR_PROJECT_ID}/${GCP_GAR_REPO}/<<parameters.image>>\"" >> $BASH_ENV
source $BASH_ENV
Expand Down

0 comments on commit 9afbe42

Please sign in to comment.