forked from LexicForLXD/Backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
95 lines (80 loc) · 2.54 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
86
87
88
89
90
91
92
93
94
image: janrtr/docker-symfony-php7-composer:3.7
stages:
- test
- release
- build
- deploy
variables:
POSTGRES_DB: syp-lxc
POSTGRES_USER: runner
POSTGRES_PASSWORD: "test"
test:php7.1:
# Select what we should cache
cache:
paths:
- vendor/
services:
- postgres:latest
stage: test
before_script:
#Install missing dependencies
- apk --no-cache add git php7-simplexml php7-ssh2
#Install phpunit
- wget https://phar.phpunit.de/phpunit.phar && chmod +x phpunit.phar && mv phpunit.phar /usr/local/bin/phpunit
#Create Test cert
- mkdir -p /srv/lexic
- echo $CERT_CRT >> /srv/lexic/client.crt
- echo $CERT_KEY >> /srv/lexic/client.key
- composer install --no-interaction
- php bin/console doctrine:schema:update --force
- php bin/console doctrine:fixtures:load --no-interaction
script:
- phpunit --coverage-text --colors=never
only:
- master
- /^feature.*$/
- /^fix.*$/
release:
before_script:
- npm install
image: node:6
only:
- master
script:
- $(npm bin)/semantic-release-gitlab
stage: release
build_docker:
image: docker:git
stage: build
services:
- docker:dind
script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- docker build -t $CI_REGISTRY/syp-lxc/backend/tagged:$(git describe --abbrev=0) -t $CI_REGISTRY/syp-lxc/backend:latest .
- docker push $CI_REGISTRY/syp-lxc/backend/tagged:$(git describe --abbrev=0)
- docker push $CI_REGISTRY/syp-lxc/backend:latest
only:
- master
deploy:dev:
image: ruby:2.1
stage: deploy
only:
- master
before_script:
# install ssh-agent
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
# run ssh-agent
- eval $(ssh-agent -s)
# add ssh key stored in SSH_PRIVATE_KEY variable to the agent store
- ssh-add <(echo "$SSH_PRIVATE_KEY")
# disable host key checking (NOTE: makes you susceptible to man-in-the-middle attacks)
# WARNING: use only in docker container, if you use it with shell you will overwrite your user's ssh config
- mkdir -p ~/.ssh
- echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
script:
# try to connect as deploy
- ssh deploy@2a02:c207:3002:3224::40
# Get latest docker image
- ssh deploy@2a02:c207:3002:3224::40 "cd lxd-api && docker-compose pull && docker-compose up -d"
#Update database schema
- ssh deploy@2a02:c207:3002:3224::40 "cd lxd-api && docker-compose exec -T web php bin/console doctrine:schema:update --force"