-
Notifications
You must be signed in to change notification settings - Fork 12
/
.gitlab-ci.yml
70 lines (63 loc) · 1.55 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
stages:
- build
- deploy
- mirror
variables:
DOCKER_DRIVER: overlay2
DEPLOY_IMAGE: $DEPLOY_IMAGE
GO_DIR: /go/src/github.com/joshrendek
GIT_STRATEGY: clone
services:
- docker:dind
build:binaries:
image: golang:1.10
stage: build
variables:
BUILD_NUMBER: $CI_PIPELINE_ID
artifacts:
untracked: true
paths:
- out/
before_script:
- mkdir -p $GO_DIR
- cp -r $CI_PROJECT_DIR $GO_DIR/hnypots-agent
- curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
- mkdir $CI_PROJECT_DIR/out
script:
- cd $GO_DIR/hnypots-agent
- dep ensure
- GOOS=linux go build -ldflags "-X main.Version=`date -u +%Y%m%d`$BUILD_NUMBER -X main.StatsdHost=$STATSD_HOST" -o honeypot
- mv honeypot $CI_PROJECT_DIR/out
- $CI_PROJECT_DIR/out/honeypot -version
deploy:agents:
image: $DEPLOY_IMAGE
stage: deploy
# tags:
# - home
artifacts:
untracked: true
paths:
- out/
variables:
BOOK: honeypots
before_script:
- eval $(ssh-agent -s)
- ssh-add <(echo "$SSH_DEPLOY_KEY")
script:
- cp out/honeypot /tmp/honeypot
- ansible honeypots -m ping
- cd /ansible
- ansible-playbook infrastructure/$BOOK.yml -f 100
mirror:
image: $DEPLOY_IMAGE
stage: mirror
before_script:
- eval $(ssh-agent -s)
- ssh-add <(echo "$SSH_DEPLOY_KEY")
- mkdir -p ~/.ssh
- ssh-keyscan -H github.com >> ~/.ssh/known_hosts
script:
- git remote add github [email protected]:joshrendek/hnypots-agent.git
- git push -f -u github HEAD:master
only:
- master