Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure we generate a proper docker tag #1675

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ deployment:
- >
test -z "${DEPLOY_BRANCH}" || test -z "${DOCKER_USER}" || (
docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS &&
docker tag weaveworks/scope:latest ${DOCKER_ORGANIZATION:-$DOCKER_USER}/scope:${CIRCLE_BRANCH//\//-} &&
docker push ${DOCKER_ORGANIZATION:-$DOCKER_USER}/scope:${CIRCLE_BRANCH//\//-}
docker tag weaveworks/scope:latest ${DOCKER_ORGANIZATION:-$DOCKER_USER}/scope:$(./image-tag "${CIRCLE_BRANCH}") &&
docker push ${DOCKER_ORGANIZATION:-$DOCKER_USER}/scope:$(./image-tag "${CIRCLE_BRANCH}")
)
# release:
# branch: /release-[0-9]+\.[0-9]+/
Expand Down
24 changes: 18 additions & 6 deletions image-tag
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,21 @@ set -o errexit
set -o nounset
set -o pipefail

WORKING_SUFFIX=$(if ! git diff --exit-code --quiet HEAD >&2; \
then echo "-WIP"; \
else echo ""; \
fi)
BRANCH_PREFIX=$(git rev-parse --abbrev-ref HEAD)
echo "${BRANCH_PREFIX//\//-}-$(git rev-parse --short HEAD)$WORKING_SUFFIX"
if [[ $# -gt 0 ]]; then
BRANCH_SUFFIX=""
BRANCH_PREFIX="${1}"
else
WORKING_SUFFIX=$(if ! git diff --exit-code --quiet HEAD >&2; \
then echo "-WIP"; \

This comment was marked as abuse.

else echo ""; \
fi)
BRANCH_SUFFIX="-$(git rev-parse --short HEAD)$WORKING_SUFFIX"
BRANCH_PREFIX=$(git rev-parse --abbrev-ref HEAD)
fi

PREFIX_LEN=$((127-$(echo -n $BRANCH_SUFFIX | wc -c)))
BRANCH_PREFIX=$(echo "${BRANCH_PREFIX}" | \
sed -e 's/[^a-zA-Z0-9_.]\+/-/g' \
-e 's/^[^a-zA-Z0-9_]*//g' | \
cut -c-${PREFIX_LEN})
echo "$BRANCH_PREFIX$BRANCH_SUFFIX"