fix: filter docker images with specified tag

pull/24376/head
Dom 2021-01-18 10:55:19 +00:00
parent 96ec8fb53a
commit 56b5751172
2 changed files with 23 additions and 5 deletions

View File

@ -107,9 +107,10 @@ jobs:
BRANCH=$(git rev-parse --abbrev-ref HEAD | tr '/' '.')
docker build -t quay.io/influxdb/fusion:$BRANCH -f docker/Dockerfile.perf .
docker push quay.io/influxdb/fusion:$BRANCH
echo "export BRANCH=${BRANCH}" >> $BASH_ENV
- run:
name: Deploy tags
command: ./.circleci/get-deploy-tags.sh
command: ./.circleci/get-deploy-tags.sh "${BRANCH}"
# Prepare the CI image used for other tasks.
#

View File

@ -1,10 +1,27 @@
#!/usr/bin/env bash
#
# Produce a deploy JSON file for a docker image on the host.
#
# Usage:
# ./get-deploy-tags DOCKER_TAG_NAME
#
# For example, if building a docker image with a tag set:
# docker build -t infuxdata.io/iox:awesome
# or manually tagged:
# docker tag infuxdata.io/iox:build infuxdata.io/iox:awesome:awesome
#
# And the image is on the host, executing this script with:
# ./get-deploy-tags "awesome"
#
# Will generate the deployment JSON file.
# Accept the git commit SHA as the first arg, or try and parse it if not set.
set -euo pipefail
DOCKER_IMAGE_TAG=${1}
DOCKER_IMAGE="quay.io/influxdb/fusion"
APPKEY="iox"
APP_NAME="iox"
DOCKER_IMAGE_INFO="$(docker images "${DOCKER_IMAGE}" --format '{{.Tag}} {{.Digest}}')"
DOCKER_IMAGE_INFO="$(docker images "${DOCKER_IMAGE}" --format '{{.Tag}} {{.Digest}}') | grep "${DOCKER_IMAGE_TAG}""
# validate that only one image with same git sha as tag is present, if not,
# write an error out and request developers to manually re-run the workflow
@ -19,7 +36,7 @@ fi
jq --null-input --sort-keys \
--arg tagDigest "${DOCKER_IMAGE_INFO}" \
--arg imgPrefix "${DOCKER_IMAGE}" \
--arg appKey "$APPKEY" \
--arg appKey "$APP_NAME" \
'$tagDigest | split(" ") as $td | {
($appKey): {
Tag: ($imgPrefix + ":" + $td[0]),