forked from plus3it/tardigrade-ci
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis.yml
76 lines (69 loc) · 2.53 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
dist: focal
language: minimal
env:
global:
- IMAGE_NAME=tardigrade-ci-test
if: branch = master OR type = pull_request OR tag is present
stages:
- lint
- test
- deploy
services:
- docker
jobs:
include:
- stage: lint
name: Project Syntax Verification
install: make lint/install
script: make -o docs/lint lint
- stage: test
name: Run Makefile unit tests
install: docker build --build-arg GITHUB_ACCESS_TOKEN=$GITHUB_ACCESS_TOKEN -t "$IMAGE_NAME" -f Dockerfile .
script: docker run "$IMAGE_NAME" bats/test
- stage: deploy
name: Deploy to GitHub Releases
if: branch = master AND type = push AND repo = plus3it/tardigrade-ci
before_script:
- |
PRIOR_VERSION=$(git describe --abbrev=0 --tags)
RELEASE_VERSION=$(grep current_version $TRAVIS_BUILD_DIR/.bumpversion.cfg | sed 's/^.*= //' )
RELEASE_BODY="* [tardigrade-ci v$RELEASE_VERSION CHANGELOG](https://github.com/plus3it/tardigrade-ci/blob/$RELEASE_VERSION/CHANGELOG.md)"
export PRIOR_VERSION RELEASE_VERSION RELEASE_BODY
script: skip
before_deploy:
- (set -x; git tag -a $RELEASE_VERSION -m $RELEASE_VERSION)
deploy:
provider: releases
api_key: $GH_RELEASES_TOKEN
name: $RELEASE_VERSION
body: $RELEASE_BODY
tag_name: $RELEASE_VERSION
target_commitish: $TRAVIS_COMMIT
draft: false
on:
branch: master
repo: plus3it/tardigrade-ci
condition: '"$PRIOR_VERSION" != "$RELEASE_VERSION"'
- stage: deploy
name: Deploy docker image to dockerhub
if: (branch = master OR tag is present) AND type != pull_request AND repo = plus3it/tardigrade-ci
script: docker build --build-arg GITHUB_ACCESS_TOKEN=$GITHUB_ACCESS_TOKEN -t "$IMAGE_NAME" -f Dockerfile .
before_deploy:
- export DOCKERHUB_TARGET="plus3it/tardigrade-ci:${TRAVIS_TAG:-latest}"
- docker tag "$IMAGE_NAME" "$DOCKERHUB_TARGET"
- echo Pushing image "$DOCKERHUB_TARGET"
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
after_deploy: echo Pushed image "$DOCKERHUB_TARGET"
deploy:
- provider: script
# push "latest" to dockerhub
script: docker push "$DOCKERHUB_TARGET"
skip_cleanup: true
on:
branch: master
- provider: script
# push "tag" to dockerhub
script: docker push "$DOCKERHUB_TARGET"
skip_cleanup: true
on:
tags: true