-
Notifications
You must be signed in to change notification settings - Fork 18
/
.travis.yml
59 lines (54 loc) · 1.84 KB
/
.travis.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
os:
- linux
dist: bionic
language: minimal
services:
- docker
# build for all pushes, as well as PRs coming from forks
# this ensures that the pipeline is triggered for internal pushes,
# PRs from forks and pushes to existing PRs from forks
if: (type == push) OR (type == pull_request AND fork == true)
stages:
- name: build
- name: publish
# for security reasons, builds from forks won't be published until merged;
# also, environment variables defined in repository settings are not
# available to builds from PRs coming from external repos
if: fork == false
before_script:
- |
export DATA_DIR="${HOME}/data"
export
if [ "$TRAVIS_BRANCH" = "dev" ]; then
export DOCKER_TAG="$(date '+%Y%m%d')"
else
export DOCKER_TAG=${TRAVIS_BRANCH//_/-}
export DOCKER_TAG=${DOCKER_TAG//\//-}
fi
jobs:
include:
- stage: build
name: Build, deploy and test
script:
- mkdir -p ${DATA_DIR}/{db,output,tmp} # create data directories
- docker-compose up -d --build
- sleep 30 # wait for services to start up
- |
test $( \
curl \
-sL \
-o /dev/null \
-w '%{http_code}' \
-X GET \
--header 'Accept: application/json' \
"${PROBE_ENDPOINT}" \
) == '200' || travis_terminate 1
- docker-compose down
- stage: publish
name: Build and publish
script:
- docker build . -t "${DOCKER_REPO_NAME}:latest" -t "${DOCKER_REPO_NAME}:${DOCKER_TAG}"
- echo "${DOCKER_TOKEN}" | docker login -u "${DOCKER_USER}" --password-stdin
- docker push "${DOCKER_REPO_NAME}:${DOCKER_TAG}"
- if [ "$TRAVIS_BRANCH" = "dev" ]; then docker push "${DOCKER_REPO_NAME}:latest"; fi
- rm ${HOME}/.docker/config.json # delete token