Skip to content
Snippets Groups Projects
Commit f004e7b4 authored by Ryan Sanford's avatar Ryan Sanford Committed by GitHub
Browse files

Merge pull request #521 from scitran/dockerhub-trigger

Add dockerhub trigger for master branch and tags
parents 2ec08bc5 4795a4e8
No related branches found
No related tags found
No related merge requests found
......@@ -13,3 +13,8 @@ script:
after_success:
- coveralls
# docker/build-trigger.sh contains the rules for when to, and not to trigger
- if [ "$TRAVIS_EVENT_TYPE" == "push" ]; then
./docker/build-trigger.sh Tag "${TRAVIS_TAG}" "${BUILD_TRIGGER_URL}" ;
./docker/build-trigger.sh Branch "${TRAVIS_BRANCH}" "${BUILD_TRIGGER_URL}" ;
fi
#!/usr/bin/env bash
# Triggers an auto-build on dockerhub for the given source control reference.
#
# Example usage: ./build-trigger Tag 1.0.0 https://registry.hub.docker.com/u/scitran/reaper/trigger/11111111-2222-3333-4444-abcdefabcdef/
set -e
if [ $# -ne 3 ] ; then
>&2 echo "Usage: $( basename $0 ) <source-control-ref-type> <source-control-ref-value> <trigger-url>"
exit 1
fi
SOURCE_CONTROL_REF_TYPE="${1}"
SOURCE_CONTROL_REF_NAME="${2}"
TRIGGER_URL="${3}"
if [ -z "${SOURCE_CONTROL_REF_TYPE}" ] ; then
>&2 echo "INFO: Source control reference type not provided, skipping build trigger."
exit 0
fi
if [ -z "${SOURCE_CONTROL_REF_NAME}" ] ; then
>&2 echo "INFO: Source control tag name not provided, skipping build trigger."
exit 0
fi
# Skip trigger unless branch is master, or for any tag.
EXEC_BUILD_TRIGGER=false
if [ "${SOURCE_CONTROL_REF_TYPE}" == "Branch" ] && [ "${SOURCE_CONTROL_REF_NAME}" == "master" ] ; then
EXEC_BUILD_TRIGGER=true
fi
if [ "${SOURCE_CONTROL_REF_TYPE}" == "Tag" ] ; then
EXEC_BUILD_TRIGGER=true
fi
if ! $EXEC_BUILD_TRIGGER ; then
>&2 echo "INFO: Source control ${SOURCE_CONTROL_REF_TYPE}: '${SOURCE_CONTROL_REF_NAME}' is not enabled for the build trigger."
exit 0
fi
# Trigger the dockerhub build
TRIGGER_PAYLOAD="{\"source_type\": \"${SOURCE_CONTROL_REF_TYPE}\", \"source_name\": \"${SOURCE_CONTROL_REF_NAME}\"}"
curl -H "Content-Type: application/json" --data "${TRIGGER_PAYLOAD}" -X POST "${TRIGGER_URL}"
>&2 echo
>&2 echo "INFO: A dockerhub build for ${SOURCE_CONTROL_REF_TYPE}: '${SOURCE_CONTROL_REF_NAME}' has been triggered."
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment