Skip to content

Commit

Permalink
fix(build): use sanitized git tag or ref for image tag
Browse files Browse the repository at this point in the history
  • Loading branch information
ssube authored and supreme-lamp[bot] committed Aug 6, 2021
1 parent 190784b commit 6ebad3c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions scripts/docker-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
set -euxo pipefail

cd ${IMAGE_ROOT}
export IMAGE_TAG="${IMAGE_NAME}:${IMAGE_VERSION}-${CI_COMMIT_REF_SLUG}"

export CLEAN_TAG="$(echo "${CI_COMMIT_TAG:-${CI_COMMIT_REF_SLUG}}" | sed -r 's/[^-_a-zA-Z0-9\\.]/-/g')"
export IMAGE_TAG="${IMAGE_NAME}:${IMAGE_VERSION}-${CLEAN_TAG}"

# pull the previous image from the same branch or master to leverage its layers
docker pull docker.artifacts.apextoaster.com/${IMAGE_TAG} || \
Expand All @@ -12,7 +14,6 @@ docker pull docker.artifacts.apextoaster.com/${IMAGE_TAG} || \

# build and test a new image
docker build -t ${IMAGE_TAG} .
docker run --rm -v $(pwd):/tests:ro --entrypoint /usr/local/bin/goss ${IMAGE_TAG} --gossfile /tests/Gossfile.yml validate

# prepare to push
function push_image() {
Expand Down

0 comments on commit 6ebad3c

Please sign in to comment.