Skip to content

Commit

Permalink
Merge branch 'is713/rename_staging_to_master' into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
sanderegg committed May 14, 2019
2 parents c7154da + eabd695 commit 40d6633
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
7 changes: 2 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,6 @@ jobs:
script: echo "Deploy master"
deploy:
- provider: script
skip_cleanup: true
script: bash ops/travis/deploy/master.sh
on:
branch: master
Expand All @@ -300,23 +299,21 @@ jobs:
script: echo "Deploy staging"
deploy:
- provider: script
skip_cleanup: true
script: bash ops/travis/deploy/staging.sh
on:
branch: staging
- stage: deployment
name: production
name: production/release
git:
depth: false
script: echo "Deploy production version $TRAVIS_TAG"
deploy:
- provider: script
skip_cleanup: true
script: ops/travis/deploy/production.sh
on:
all_branches: true
tags: true
condition: $TRAVIS_TAG =~ ^staging-\d{4}-[01][1-9]-[0123]\d.\d+.\b[0-9a-f]{5,40}\b$
condition: $TRAVIS_TAG =~ ^v\d+.\d+.\d+$
notifications:
email:
on_success: never
Expand Down
6 changes: 5 additions & 1 deletion ops/travis/deploy/production.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ IFS=$'\n\t'

# pull the tagged staging build
export DOCKER_IMAGE_PREFIX=${DOCKER_REGISTRY}/
export DOCKER_IMAGE_TAG="${TRAVIS_TAG}"
# find the docker image tag
export TAG="${TRAVIS_TAG}"
export ORG=${DOCKER_REGISTRY}
export REPO="webserver"
export DOCKER_IMAGE_TAG=$(exec ops/travis/helpers/find_staging_version.sh)
make pull

# show current images on system
Expand Down
20 changes: 10 additions & 10 deletions ops/travis/helpers/find_staging_version.sh
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
#!/bin/bash
# Usage: find_staging_version.sh
#
# returns the full image tag corresponding to the git tag name that shall be used

# http://redsymbol.net/articles/unofficial-bash-strict-mode/
set -euo pipefail
IFS=$'\n\t'

GIT_COMMIT_SHA=$(git show-ref -s ${TRAVIS_TAG})
ORG=${DOCKER_REGISTRY}
REPO="webserver"
echo "Retrieving SHA for tag ${TAG}"
GIT_COMMIT_SHA=$(git show-ref -s ${TAG})
echo "Found SHA for tag ${GIT_COMMIT_SHA}"

# get token
echo "Retrieving token ..."
TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d '{"username": "'${DOCKER_USERNAME}'", "password": "'${DOCKER_PASSWORD}'"}' https://hub.docker.com/v2/users/login/ | jq -r .token)

# get list of repositories
echo "Retrieving repository list ..."
REPO_LIST=$(curl -s -H "Authorization: JWT ${TOKEN}" https://hub.docker.com/v2/repositories/${ORG}/?page_size=100 | jq -r '.results|.[]|.name')

# output images & tags
echo
echo "Images and tags for organization: ${ORG}"
echo
echo "in repo ${REPO}"
IMAGE_TAGS=$(curl -s -H "Authorization: JWT ${TOKEN}" https://hub.docker.com/v2/repositories/${ORG}/${REPO}/tags/?page_size=100 | jq -r '.results|.[]|.name')
for j in ${IMAGE_TAGS}
do
echo " - ${j}"
done
if [[ ${j} =~ ${GIT_COMMIT_SHA} ]]; then
echo "${j}"
exit 0
fi
done

0 comments on commit 40d6633

Please sign in to comment.