forked from snabbco/snabb
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.gitlab-ci.yml
85 lines (75 loc) · 1.6 KB
/
.gitlab-ci.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
image: docker-hub.squiz.net/hosting/snabb-docker:latest
variables:
SSH_CMD: "ssh -o StrictHostKeychecking=no"
# Upload private key to runner
before_script:
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- echo "$SNABB_SSH_PRIVATE_KEY" | tr -d '\r' > ~/.ssh/id_rsa
- chmod 0600 ~/.ssh/id_rsa
# Remove private key just in case
after_script:
- rm ~/.ssh/id_rsa
stages:
- build
#- test
- deploy
build:
stage: build
tags:
- "centos"
- "7"
script:
- make -j
artifacts:
paths:
- src/snabb
name: "release-$CI_COMMIT_REF_NAME"
expire_in: 5 days
# Cache luajit build
cache:
paths:
- "lib/luajit/**/*.o"
#test:
# stage: test
# tags:
# - "centos"
# - "7"
# script:
# - make -j
# - cd src
# - make test
# artifacts:
# paths:
# - src/testlog/*
# name: "testlogs-$CI_COMMIT_REF_NAME"
# expire_in: 1 days
#
# # Cache luajit build
# cache:
# paths:
# - "lib/luajit/**/*.o"
deploy:dev:
stage: deploy
environment:
name: dev
tags:
- "centos"
- "7"
dependencies:
- build
script:
- for HOST in $SNABB_HOSTS; do rsync -arvze "${SSH_CMD}" src/snabb root@$HOST:/$SNABB_PATH; ${SSH_CMD} $HOST systemctl restart snabb; done;
# Trigger deployment of config
config:dev:
stage: deploy
environment:
name: dev
tags:
- "centos"
- "7"
dependencies:
- build
script:
- "curl -X POST -F token=${SNABB_CONFIG_BUILD_TOKEN} -F ref=${CI_COMMIT_REF_NAME} https://gitlab.squiz.net/api/v4/projects/${SNABB_CONFIG_BUILD_REPO}/trigger/pipeline"
retry: 2 # Curl back to gitlab can sometimes fail, retry