-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis.yml
69 lines (58 loc) 路 1.88 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
dist: bionic
os: linux
language: shell
language: go
go:
- 1.12.x
services:
- docker
env:
global:
- DOCKER_PLATFORMS="linux/amd64,linux/arm64,linux/ppc64le,linux/s390x,linux/386,linux/arm/v7,linux/arm/v6"
- APP_FOLDER=/go/src/github.com/moikot/metalogin/
git:
depth: 1
before_install:
- go get github.com/mattn/goveralls
stages:
- name: build and test
if: tag IS blank
- name: deploy
if: branch = master OR tag =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/
matrix:
include:
- stage: build and test
script:
# Restore packages using moikot/golang-dep
- >-
docker run --rm -v $(pwd):${APP_FOLDER} -w ${APP_FOLDER}
-u $(id -u ${USER}):$(id -g ${USER})
moikot/golang-dep ensure -vendor-only
# Run all the tests and report the coverage
- go test -covermode=count -coverprofile=profile.cov -coverpkg=./... ./...
- $GOPATH/bin/goveralls -service=travis-ci
- stage: deploy
script:
# Get scripts for building Docker images
- id=$(docker create moikot/docker-tools)
- docker cp $id:/scripts.sh /tmp/scripts.sh && docker rm -v $id
# Update docker to the latest version and enable BuildKit
- /tmp/scripts.sh update_docker
# Login to Doker Hub
- >-
echo "${DOCKER_PASSWORD}" |
docker login -u "${DOCKER_USERNAME}" --password-stdin
# Build multi-platform image and push it
- >-
/tmp/scripts.sh build_images
${TRAVIS_REPO_SLUG} ${TRAVIS_BRANCH} ${DOCKER_PLATFORMS}
--push --build-arg APP_FOLDER=${APP_FOLDER}
# Push readme file for a tag
- |
if [ "${TRAVIS_BRANCH}" != "master" ]; then
/tmp/scripts.sh push_readme \
${TRAVIS_REPO_SLUG} README.md \
${DOCKER_USERNAME} ${DOCKER_PASSWORD}
fi
notifications:
email: false