This repository was archived by the owner on Nov 5, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.travis.yml
87 lines (87 loc) · 3.14 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
language: python
sudo: true
services:
- postgresql
- docker
cache:
- pip
- yarn
- npm
before_script:
- COMMIT_ID=$(git rev-parse --short HEAD)
- echo $COMMIT_ID
install:
- pip install -r wangwang/requirements.txt
- pip install -r wangwang/dev-requirements.txt
- pip freeze
env:
- DOCKER_USERNAME=zhaoqi99
jobs:
include:
- stage: test
name: "Code style"
python: 3.6
script:
- cd wangwang && make check
- stage: test
name: "Unit test"
python: 3.6
script:
- psql -c 'create database test;' -U postgres
- cd wangwang
- make makemigrations
- make migrate
- make test
env:
- ENV=test
- stage: build
name: "Build backend image"
install: skip
python: 3.6
script:
- cd wangwang
- docker build -t wangwang .
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
- docker images
- docker tag wangwang $DOCKER_USERNAME/wangwang:$COMMIT_ID
- docker push $DOCKER_USERNAME/wangwang:$COMMIT_ID
- if [ "$TRAVIS_BRANCH" = "master" ]; then docker tag wangwang $DOCKER_USERNAME/wangwang:latest; fi;
- if [ "$TRAVIS_BRANCH" = "master" ]; then docker push $DOCKER_USERNAME/wangwang:latest; fi;
- echo "Build backend image Success!"
- docker run --name=wangwang --net=host --restart=always -d $DOCKER_USERNAME/wangwang:latest
- stage: build
name: "Build frontend image"
install: skip
script:
- cd miaomiao
- docker build -t miaomiao .
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
- docker images
- docker tag miaomiao $DOCKER_USERNAME/miaomiao:$COMMIT_ID
- docker push $DOCKER_USERNAME/miaomiao:$COMMIT_ID
- if [ "$TRAVIS_BRANCH" = "master" ]; then docker tag miaomiao $DOCKER_USERNAME/miaomiao:latest; fi;
- if [ "$TRAVIS_BRANCH" = "master" ]; then docker push $DOCKER_USERNAME/miaomiao:latest; fi;
- echo "Build frontend image Success!"
- docker run --name=miaomiao --net=host --restart=always -d $DOCKER_USERNAME/miaomiao:latest
- stage: deploy
name: "Deploy backend"
install: skip
script:
- sudo apt-get install sshpass -y
- export SSHPASS=$SERVER_PASSWOED
- sshpass -e ssh root@$PRO_IP -o stricthostkeychecking=no 'docker pull zhaoqi99/wangwang:latest && docker stop wangwang && docker rm wangwang && docker run --name=wangwang --net=host --restart=always -d zhaoqi99/wangwang:latest && exit'
- echo "Deploy backend success!"
- stage: deploy
name: "Deploy frontend"
install: skip
script:
- sudo apt-get install sshpass -y
- export SSHPASS=$SERVER_PASSWOED
- sshpass -e ssh root@$PRO_IP -o stricthostkeychecking=no 'docker pull zhaoqi99/miaomiao:latest && docker stop miaomiao && docker rm miaomiao && docker run --name=miaomiao --net=host --restart=always -d zhaoqi99/miaomiao:latest && exit'
- echo "Deploy frontend Success!"
stages:
- test
- build
- name: deploy
if: branch = master
fast_finish: true