Skip to content

Commit

Permalink
Travis / simplied tags /b
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalandy committed May 1, 2018
1 parent fcb7bef commit 69e8e94
Showing 1 changed file with 22 additions and 19 deletions.
41 changes: 22 additions & 19 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,18 @@ services:

branches:
except:
- tmp11

#env:
# global:
- tmp99

# Secret DOCKER_PASSWORD managed by Travis:
# See https://docs.travis-ci.com/user/environment-variables/#Defining-Variables-in-Repository-Settings
#
# In a commit, by using [ci skip] it will skip Travis build
#
# THIS_SHA_SHORT=$(git rev-parse --short HEAD)
#
# In the master branch, the GHOST_VERSION is parsed from the Dockerfile https://github.com/firepress-org/ghostfire/blob/master/Dockerfile
# WIP in the followrelease branch, the GHOST_VERSION is parsed from: https://github.com/TryGhost/Ghost/releases

# Secret DOCKER_PASSWORD managed by Travis:
# See https://docs.travis-ci.com/user/environment-variables/#Defining-Variables-in-Repository-Settings
# In a commit, by using [ci skip] it will skip Travis build.

before_install:
- sudo apt-get -qq update
- sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce
Expand All @@ -29,12 +32,8 @@ addons:
install:
- git clone https://github.com/docker-library/official-images.git ~/official-images

# In the master branch, the GHOST_VERSION is parsed from the Dockerfile https://github.com/firepress-org/ghostfire/blob/master/Dockerfile
# WIP in the followrelease branch, the GHOST_VERSION is parsed from: https://github.com/TryGhost/Ghost/releases
# THIS_SHA_SHORT=$(git rev-parse --short HEAD)
before_script:
- GHOST_VERSION_DOCKERFILE="$(cat Dockerfile | grep GHOST_VERSION= | head -n 1 | grep -o '".*"' | sed 's/"//g')"
- SUB_VERSION="$(cat Dockerfile | grep SUB_VERSION= | head -n 1 | grep -o '".*"' | sed 's/"//g')"
- GHOST_LATEST_RELEASE="$(git ls-remote --tags https://github.com/TryGhost/Ghost.git | cut -d$'\t' -f2 | grep -E '^refs/tags/[0-9]+\.[0-9]+' | cut -d/ -f3 | sort -rV | head -n1)"
- GHOST_CLI_LATEST_RELEASE="$(git ls-remote --tags https://github.com/TryGhost/Ghost-CLI.git | cut -d$'\t' -f2 | grep -E '^refs/tags/[0-9]+\.[0-9]+' | cut -d/ -f3 | sort -rV | head -n1)"
- GHOST_VERSION="$GHOST_VERSION_DOCKERFILE"
Expand All @@ -56,12 +55,14 @@ script:
- uname -a;
- docker build -t "$IMAGE_SHA_SHORT" .
- docker run -d --name "$CONTAINER_NAME" -p 2368:2368 -e url=http://localhost:2368 -e NODE_ENV=production "$IMAGE_SHA_SHORT"

- echo "Ensure $CONTAINER_NAME is starting..."
- until $(curl --output /dev/null --silent --head --fail http://localhost:2368); do
echo "Waiting for $CONTAINER_NAME container to run...";
sleep 3;
done
- curl http://localhost:2368 | grep "The professional publishing platform"

- echo "Starting official docker unit test on the image..."
- ~/official-images/test/run.sh "$IMAGE_SHA_SHORT"

Expand All @@ -78,21 +79,23 @@ after_script:
- docker exec -it "$CONTAINER_NAME" curl -Is --head "http://localhost:2368" | grep -F -o "HTTP/1.1 200 OK" || echo "Error --> http://localhost:2368"
- docker rm -f "$CONTAINER_NAME";

- echo && echo "GHOST_VERSION_DOCKERFILE=$GHOST_VERSION_DOCKERFILE" && echo "SUB_VERSION=$SUB_VERSION" && echo "GHOST_LATEST_RELEASE=$GHOST_LATEST_RELEASE" && echo "GHOST_CLI_LATEST_RELEASE=$GHOST_CLI_LATEST_RELEASE" && echo "GHOST_VERSION=$GHOST_VERSION" && echo && echo "IMAGE_EDGE=$IMAGE_EDGE" && echo "IMAGE_SHA_SHORT=$IMAGE_SHA_SHORT" && echo "IMAGE_VERSION=$IMAGE_VERSION" && echo "IMAGE_SHA_LONG=$IMAGE_SHA_LONG" && echo "IMAGE_DATE=$IMAGE_DATE" && echo && echo "#IMAGE_EDGE=$IMAGE_EDGE" && echo "#IMAGE_SHA_SHORT=$IMAGE_SHA_SHORT" && echo "#IMAGE_VERSION=$IMAGE_VERSION" && echo "#IMAGE_SHA_LONG=$IMAGE_SHA_LONG" && echo "#IMAGE_DATE=$IMAGE_DATE";
- echo && echo "GHOST_VERSION_DOCKERFILE=$GHOST_VERSION_DOCKERFILE" && echo "GHOST_LATEST_RELEASE=$GHOST_LATEST_RELEASE" && echo "GHOST_CLI_LATEST_RELEASE=$GHOST_CLI_LATEST_RELEASE" && echo "GHOST_VERSION=$GHOST_VERSION" && echo && echo "IMAGE_SHA_SHORT=$IMAGE_SHA_SHORT" && echo "IMAGE_DATE=$IMAGE_DATE" && echo "IMAGE_VERSION=$IMAGE_VERSION" && echo "IMAGE_EDGE=$IMAGE_EDGE" && echo && echo "#IMAGE_SHA_SHORT=$IMAGE_SHA_SHORT" && echo "#IMAGE_DATE=$IMAGE_DATE" && echo "#IMAGE_VERSION=$IMAGE_VERSION" && echo "#IMAGE_EDGE=$IMAGE_EDGE";

after_success:
#docker build -t "$IMAGE_SHA_SHORT" (already built)
- if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_BRANCH" == "master" ] && [ "$DOCKER_REPO_PREFIX" != "" ] && [ "$DOCKER_REPO_NAME" != "" ] && [ "$DOCKER_USERNAME" != "" ] && [ "$DOCKER_PASSWORD" != "" ]; then
# docker build -t "$IMAGE_SHA_SHORT" (already built)
after_success:
- if [ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$DOCKER_REPO_PREFIX" != "" ] && [ "$DOCKER_REPO_NAME" != "" ] && [ "$DOCKER_USERNAME" != "" ] && [ "$DOCKER_PASSWORD" != "" ]; then
echo "$DOCKER_PASSWORD" | docker login --username "$DOCKER_USERNAME" --password-stdin;

docker push "$IMAGE_SHA_SHORT";

docker build -t "$IMAGE_VERSION" .;
docker push "$IMAGE_VERSION";

docker build -t "$IMAGE_DATE" .;
docker push "$IMAGE_DATE";

docker build -t "$IMAGE_VERSION" .;
docker push "$IMAGE_VERSION";

docker build -t "$IMAGE_EDGE" .;
docker push "$IMAGE_EDGE";
else
exit 1
fi

0 comments on commit 69e8e94

Please sign in to comment.