-
Notifications
You must be signed in to change notification settings - Fork 46
/
.travis.yml
53 lines (48 loc) · 1.65 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
sudo: true
dist: trusty
language: minimal
if: branch = master
services:
- docker
env:
global:
- DOCKER_USERNAME=alatas
- AUTHOR=alatas
- REPO_NAME=squid-alpine-ssl
before_script:
- export TAG=$(echo $TRAVIS_COMMIT_MESSAGE | egrep -o 'r[0-9]+' | head -1)
- echo $TAG
script:
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
- docker build -t $DOCKER_USERNAME/$REPO_NAME:latest .
- docker images
- docker push $DOCKER_USERNAME/$REPO_NAME:latest
- docker tag $DOCKER_USERNAME/$REPO_NAME:latest $DOCKER_USERNAME/$REPO_NAME:$TAG
- docker push $DOCKER_USERNAME/$REPO_NAME:$TAG
before_deploy:
- git tag -f "$TAG" -m "$TRAVIS_COMMIT_MESSAGE"
- git tag
- export DEPLOY_DOCKER=$TRAVIS_BUILD_DIR/../deploy_docker
- mkdir -p $DEPLOY_DOCKER
- mkdir -p $DEPLOY_DOCKER/cache
- mkdir -p $DEPLOY_DOCKER/cert
- mkdir -p $DEPLOY_DOCKER/conf
- mkdir -p $DEPLOY_DOCKER/log
- cp -f $TRAVIS_BUILD_DIR/*.yml $DEPLOY_DOCKER
- sed -i s/latest/$TAG/g $DEPLOY_DOCKER/docker-compose.yml
- cp -f $TRAVIS_BUILD_DIR/cache/.placeholder $DEPLOY_DOCKER/cache
- cp -f $TRAVIS_BUILD_DIR/cert/.placeholder $DEPLOY_DOCKER/cert
- cp -f $TRAVIS_BUILD_DIR/conf/squid.conf $DEPLOY_DOCKER/conf
- cp -f $TRAVIS_BUILD_DIR/log/.placeholder $DEPLOY_DOCKER/log
- rm -f "$DEPLOY_DOCKER/../$REPO_NAME-$TAG-docker.zip" && cd $DEPLOY_DOCKER/ && zip -r -J "$DEPLOY_DOCKER/../$REPO_NAME-$TAG-docker.zip" *
- cd $TRAVIS_BUILD_DIR/
deploy:
provider: releases
api_key: $GITHUB_TOKEN
file:
- "$DEPLOY_DOCKER/../$REPO_NAME-$TAG-docker.zip"
overwrite: true
skip_cleanup: true
on:
repo: $AUTHOR/$REPO_NAME
all_branches: true