This repository has been archived by the owner on Feb 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy path.travis.yml
125 lines (108 loc) · 4.03 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
sudo: required
# Disable git shallow clone. We need full history for validating copyright year of each file.
git:
depth: false
services:
- docker
addons:
apt:
packages:
- "python3"
- "python3-pip"
stages:
- Check commits
- Tests
- Build and Push
jobs:
include:
- stage: Check commits
before_script:
# Rename the branch we're on, so that it's not in the way for the
# subsequent fetch. It's ok if this fails, it just means we're not on any
# branch.
- git branch -m temp-branch || true
# Git trick: Fetch directly into our local branches instead of remote
# branches.
- git fetch origin 'refs/heads/*:refs/heads/*'
# Get last remaining tags, if any.
- git fetch --tags origin
- git clone git://github.com/mendersoftware/mendertesting /tmp/mendertesting
script:
# Check commit compliance.
- /tmp/mendertesting/check_commits.sh
- /tmp/mendertesting/check_license.sh
- stage: Build and Push
env:
- DOCKER_REPOSITORY=mendersoftware/mender-conductor
- SERVICE_DIR=server
before_script:
# Latest commit SHA for service
- COMMIT=$(git log -n 1 --pretty=format:%H)
script:
# Build docker image from docker file
- sudo docker build -t $DOCKER_REPOSITORY ./$SERVICE_DIR
before_deploy:
# Master is always lastest
- if [ ! -z "$TRAVIS_TAG" ]; then export IMAGE_TAG=$TRAVIS_TAG; else export IMAGE_TAG=$TRAVIS_BRANCH; fi
- docker tag $DOCKER_REPOSITORY $DOCKER_REPOSITORY:$IMAGE_TAG
# Upload image to docker registry only on PUSH
- docker login --username=$DOCKER_HUB_USERNAME --password=$DOCKER_HUB_PASSWORD
- docker push $DOCKER_REPOSITORY:$IMAGE_TAG
- if [ "$TRAVIS_BRANCH" = master ]; then
export COMMIT_TAG="$TRAVIS_BRANCH"_"$COMMIT";
docker tag $DOCKER_REPOSITORY $DOCKER_REPOSITORY:$COMMIT_TAG;
docker push $DOCKER_REPOSITORY:$COMMIT_TAG;
fi;
deploy:
# Force before_deploy for branches
-
provider: script
script: /bin/true
on:
all_branches: true
# Force before_deploy for tags
-
provider: script
script: /bin/true
on:
tags: true
all_branches: true
after_deploy:
- export TRAVIS_BRANCH IMAGE_TAG
- ./trigger-mender-conductor-enterprise.sh
- stage: Build and Push
env:
- DOCKER_REPOSITORY=mendersoftware/email-sender
- SERVICE_DIR=workers/send_email
before_script:
# Latest commit SHA for service
- COMMIT=$(git log -n 1 --pretty=format:%H)
script:
# Build docker image from docker file
- sudo docker build -t $DOCKER_REPOSITORY ./$SERVICE_DIR
before_deploy:
# Master is always lastest
- if [ ! -z "$TRAVIS_TAG" ]; then export IMAGE_TAG=$TRAVIS_TAG; else export IMAGE_TAG=$TRAVIS_BRANCH; fi
- docker tag $DOCKER_REPOSITORY $DOCKER_REPOSITORY:$IMAGE_TAG
# Upload image to docker registry only on PUSH
- docker login --username=$DOCKER_HUB_USERNAME --password=$DOCKER_HUB_PASSWORD
- docker push $DOCKER_REPOSITORY:$IMAGE_TAG
- if [ "$TRAVIS_BRANCH" = master ]; then
export COMMIT_TAG="$TRAVIS_BRANCH"_"$COMMIT";
docker tag $DOCKER_REPOSITORY $DOCKER_REPOSITORY:$COMMIT_TAG;
docker push $DOCKER_REPOSITORY:$COMMIT_TAG;
fi;
deploy:
# Force before_deploy for branches
-
provider: script
script: /bin/true
on:
all_branches: true
# Force before_deploy for tags
-
provider: script
script: /bin/true
on:
tags: true
all_branches: true