This repository has been archived by the owner on Oct 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.travis.yml
65 lines (58 loc) · 2.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
60
61
62
63
64
65
dist: trusty
sudo: true
language: generic
# All PRs already get a build.
# This restricts only master to get a build for pushes.
branches:
only:
- master
services:
- docker
# publish to opendoor gothumb on non-master branch
stages:
- name: publish to opendoor-gothumb
if: (branch = master) AND (type = pull_request)
- name: publish to gothumb
if: (branch = master) AND (type != pull_request)
install: true
before_install:
- docker --version
- docker login -u "$DOCKERHUB_USER" -p "$DOCKERHUB_PASS"
jobs:
include:
- stage: publish to opendoor-gothumb
install:
- docker pull opendoor/gothumb:master-latest
- docker build -t gothumb-local --file=Dockerfile . --cache-from opendoor/gothumb:master-latest
- docker history gothumb-local
script:
- IMAGE_REPO_NAME="opendoor-gothumb" # e.g. opendoor-labs/myrepo => opendoor-myrepo
- echo "$IMAGE_REPO_NAME"
- echo "$TRAVIS_COMMIT" > GIT_DEPLOY_SHA
- docker build -t "opendoor/opendoor-gothumb:${TRAVIS_COMMIT:0:7}" --file=Dockerfile . --cache-from opendoor-gothumb-local
- docker push "opendoor/opendoor-gothumb:${TRAVIS_COMMIT:0:7}"
# By default Travis builds the merge commit of the HEAD of the PR with the base branch.
# This is a bit confusing as the commit sha which is built is not present in the repo itself;
# it's the transient merge commit with base. This behavior is good for unit tests, but
# strange for building images.
# ref: https://docs.travis-ci.com/user/pull-requests#How-Pull-Requests-are-Tested
- if [ -n "$TRAVIS_PULL_REQUEST_SHA" ]; then
git checkout "$TRAVIS_PULL_REQUEST_SHA";
echo "$TRAVIS_PULL_REQUEST_SHA" > GIT_DEPLOY_SHA;
docker build -t "opendoor/opendoor-gothumb:${TRAVIS_PULL_REQUEST_SHA:0:7}" --file=Dockerfile . --cache-from gothumb-local;
docker push "opendoor/opendoor-gothumb:${TRAVIS_PULL_REQUEST_SHA:0:7}";
fi
- stage: publish to gothumb
install:
- docker pull opendoor/gothumb:master-latest
- docker build -t gothumb-local --file=Dockerfile . --cache-from opendoor/gothumb:master-latest
- docker history gothumb-local
script:
- docker build -t "opendoor/gothumb:${TRAVIS_COMMIT:0:7}" --file=Dockerfile . --cache-from gothumb-local
- docker push "opendoor/gothumb:${TRAVIS_COMMIT:0:7}"
- if [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_BRANCH" == "master" ]; then
docker build -t "opendoor/gothumb:${TRAVIS_COMMIT:0:7}" --file=Dockerfile . --cache-from gothumb-local;
docker push "opendoor/gothumb:${TRAVIS_COMMIT:0:7}";
docker build -t "opendoor/gothumb:master-latest" --file=Dockerfile . --cache-from gothumb-local;
docker push "opendoor/gothumb:master-latest";
fi