-
-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make sure the latest release and stable tags match. Closes #56
- Moved the push script into a standalone file - scripts/docker-push.sh
- Loading branch information
Showing
2 changed files
with
81 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#!/usr/bin/env bash | ||
|
||
# ----- Helper functions ----- # | ||
|
||
is_edge () | ||
{ | ||
[[ "${TRAVIS_BRANCH}" == "develop" ]] | ||
} | ||
|
||
is_stable () | ||
{ | ||
[[ "${TRAVIS_BRANCH}" == "master" ]] | ||
} | ||
|
||
is_release () | ||
{ | ||
[[ "${TRAVIS_TAG}" != "" ]] | ||
} | ||
|
||
# Check whether the current build is for a pull request | ||
is_pr () | ||
{ | ||
[[ "${TRAVIS_PULL_REQUEST}" == "false" ]] | ||
} | ||
|
||
is_lates () | ||
{ | ||
[[ "${VERSION}" == "${LATEST_VERSION}" ]] | ||
} | ||
|
||
# Tag and push an image | ||
tag_and_push () | ||
{ | ||
local source=$1 | ||
local target=$2 | ||
|
||
# Base image | ||
docker tag ${source} ${target} | ||
docker push ${target} | ||
|
||
# Cloud9 flavor | ||
docker tag ${source}-ide ${target}-ide | ||
docker push ${target}-ide | ||
} | ||
|
||
# ---------------------------- # | ||
|
||
# Skip pull request builds | ||
is_pr && exit | ||
|
||
# Figure out docker image tag | ||
IMAGE_TAG_EDGE="edge-php${VERSION}" | ||
IMAGE_TAG_STABLE="php${VERSION}" | ||
IMAGE_TAG_RELEASE="${TRAVIS_TAG:1:3}-php${VERSION}" | ||
|
||
if is_edge; then | ||
IMAGE_TAG=${IMAGE_TAG_EDGE} | ||
elif is_stable; then | ||
IMAGE_TAG=${IMAGE_TAG_STABLE} | ||
elif is_release; then | ||
IMAGE_TAG=${IMAGE_TAG_RELEASE} | ||
else | ||
# Exit if not on develop, master or release tag | ||
exit | ||
fi | ||
|
||
docker login -u "${DOCKER_USER}" -p "${DOCKER_PASS}" | ||
|
||
# Push images | ||
tag_and_push ${REPO}:build-${VERSION} ${REPO}:${IMAGE_TAG} | ||
|
||
# For releases - push the stable image tags again to have them match the release tag | ||
if is_release; then | ||
tag_and_push ${REPO}:build-${VERSION} ${REPO}:${IMAGE_TAG} | ||
fi | ||
|
||
# Push the "latest" tag for stable and release builds | ||
if is_lates && (is_stable || is_release); then | ||
tag_and_push ${REPO}:build-${VERSION} ${REPO}:latest | ||
fi |