Merge pull request #254 from bioperl/hyphaltip-bug253-patch-1
[bioperl-live.git] / travis_scripts / trigger-dockerhub.sh
blob36bb789ce963a683ba5dcc384c0e6badedde8dcd
1 #!/bin/bash
3 set -e
5 # the Docker Hub API endpoint
6 dockerapi="https://registry.hub.docker.com/u/bioperl/bioperl/trigger"
8 ## Travis runs a build for several versions of Perl, but we want to
9 ## trigger only for the same version of Perl as is running in the
10 ## Docker container
11 docker_perl="5.18"
13 if [[ ${TRAVIS_PERL_VERSION:0:4} != "$docker_perl" ]] ; then
14 echo "Triggering Docker Hub only for Perl $docker_perl, not $TRAVIS_PERL_VERSION"
15 exit 0
18 if [[ "$TRAVIS_PULL_REQUEST" != "false" ]] ; then
19 echo "Not triggering Docker Hub for pull requests."
20 exit 0
23 if [[ -z "$DOCKERHUB_TOKEN" ]] ; then
24 echo "No API token for Docker Hub, add to repository settings."
25 exit 1
28 if [[ -n "$COVERAGE" && "$COVERAGE" != "0" ]] ; then
29 echo "Not triggering Docker Hub for code coverage build."
30 exit 0
33 ## Should check for tag names that indicate release candidates rather
34 ## than release names, and then skip those.
35 ## However, this is already taken care of by the regular expression
36 ## for whitelisting branches.
38 if [[ -n "$TRAVIS_TAG" && "$TRAVIS_TAG" != "false" ]] ; then
39 # if we are building a whitelisted tag, we trigger the stable image
40 echo "Triggering rebuild of Docker image bioperl/bioperl:stable"
41 curl -H "Content-Type: application/json" \
42 --data '{"docker_tag": "stable"}' \
43 -X POST $dockerapi/$DOCKERHUB_TOKEN/
44 elif [[ "$TRAVIS_BRANCH" != "master" ]] ; then
45 # if someone were to create a branch that matches the whitelisting
46 # pattern, we skip that here, and only trigger on master
47 echo "Not triggering Docker Hub for branches other than master"
48 else
49 # not a pull request, not a tag, and the branch is master
50 echo "Triggering rebuild of Docker image bioperl/bioperl:latest"
51 curl -H "Content-Type: application/json" \
52 --data '{"docker_tag": "latest"}' \
53 -X POST $dockerapi/$DOCKERHUB_TOKEN/