Initial code drop.
This commit is contained in:
commit
1447b6640a
15 changed files with 685 additions and 0 deletions
39
hooks/post_push
Executable file
39
hooks/post_push
Executable file
|
@ -0,0 +1,39 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Post push hook for Docker Automated Build.
|
||||
#
|
||||
# This hook adds the 'latest' tag to the image.
|
||||
#
|
||||
|
||||
set -e # Exit immediately if a command exits with a non-zero status.
|
||||
set -u # Treat unset variables as an error.
|
||||
|
||||
source custom_hook_env
|
||||
|
||||
echo "Environment variables:
|
||||
IMAGE_NAME=$IMAGE_NAME
|
||||
DOCKER_REPO=$DOCKER_REPO
|
||||
DOCKER_TAG=$DOCKER_TAG
|
||||
SOURCE_BRANCH=$SOURCE_BRANCH
|
||||
IMAGE_VERSION=$IMAGE_VERSION
|
||||
"
|
||||
|
||||
if [[ "$DOCKER_TAG" =~ v[0-9]+\.[0-9]+\.[0-9]+-alpha[0-9]+$ ]]; then
|
||||
DOCKER_NEWTAG="$(echo "$DOCKER_TAG" | sed 's/-alpha[0-9]\+$/-alpha/')"
|
||||
elif [[ "$DOCKER_TAG" =~ v[0-9]+\.[0-9]+\.[0-9]+-beta[0-9]+$ ]]; then
|
||||
DOCKER_NEWTAG="$(echo "$DOCKER_TAG" | sed 's/-beta[0-9]\+$/-beta/')"
|
||||
elif [[ "$DOCKER_TAG" =~ v[0-9]+\.[0-9]+\.[0-9]+-rc[0-9]+$ ]]; then
|
||||
DOCKER_NEWTAG="$(echo "$DOCKER_TAG" | sed 's/-rc[0-9]\+$/-rc/')"
|
||||
elif [[ "$DOCKER_TAG" =~ v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||
DOCKER_NEWTAG="latest"
|
||||
else
|
||||
echo "ERROR: Invalid docker tag."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Adding tag '$DOCKER_NEWTAG' to image..."
|
||||
docker tag $IMAGE_NAME ${DOCKER_REPO}:$DOCKER_NEWTAG
|
||||
echo "Pushing image..."
|
||||
docker push ${DOCKER_REPO}:$DOCKER_NEWTAG
|
||||
|
||||
echo "post_push hook terminated successfully."
|
Loading…
Add table
Add a link
Reference in a new issue