-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
executable file
·108 lines (101 loc) · 2.94 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
stages:
- manual-clean
- lint
- build
- compose
- testing
- deploy
variables:
SSH_COMMAND: $SSH_COMMAND
DB_HOST: $DB_HOST
build:
stage: build
tags:
- uberserver
script:
- docker-compose -f docker-compose.ci.yaml down --remove-orphans
- cp -n .env.test .env.test.local
- sed -i 's/uberserver/'"$DB_HOST"'/g' .env
- sed -i 's/uberserver/'"$DB_HOST"'/g' .env.test.local
- docker-compose -f docker-compose.ci.yaml build php-fpm
- rm .env.test.local -f
- docker-compose -f docker-compose.ci.yaml up -d
after_script:
- >
if [ $CI_JOB_STATUS == 'success' ]; then
echo 'Success'
else
echo 'Dropping build files'
docker-compose -f docker-compose.ci.yaml down --remove-orphans
docker image rm uberserver-symfony_php-fpm
fi
compose:
stage: compose
interruptible: true
tags:
- uberserver
dependencies:
- build
script:
- docker-compose -f docker-compose.ci.yaml exec -T php-fpm composer install --prefer-dist --no-ansi --no-interaction --no-progress
- docker-compose -f docker-compose.ci.yaml exec -T php-fpm php -v
- docker-compose -f docker-compose.ci.yaml exec -T php-fpm chmod 777 -R ./var ./tests/_output ./tests/_support
tests:
stage: testing
tags:
- uberserver
dependencies:
- compose
script:
- docker-compose -f docker-compose.ci.yaml exec -T php-fpm php bin/console d:d:d --force
- docker-compose -f docker-compose.ci.yaml exec -T php-fpm php bin/console d:d:c
- docker-compose -f docker-compose.ci.yaml exec -T php-fpm php bin/console doctrine:migrations:migrate --no-interaction
- docker-compose -f docker-compose.ci.yaml exec -T php-fpm ./vendor/codeception/codeception/codecept build
- docker-compose -f docker-compose.ci.yaml exec -T php-fpm ./vendor/codeception/codeception/codecept run
- docker-compose -f docker-compose.ci.yaml down --remove-orphans
after_script:
- >
if [ $CI_JOB_STATUS == 'success' ]; then
echo 'Success'
docker image rm uberserver-symfony_php-fpm
else
echo 'Dropping build files'
docker-compose -f docker-compose.ci.yaml down --remove-orphans
docker image rm uberserver-symfony_php-fpm
fi
clean:
stage: manual-clean
tags:
- uberserver
script:
- docker-compose -f docker-compose.ci.yaml down --remove-orphans
- docker system prune -a -f
when: manual
psalm:
stage: lint
script:
- docker-compose -f docker-compose.ci.yaml exec -T php-fpm php /var/www/vendor/bin/psalm --no-cache --output-format=phpstorm
when: manual
deploy_prod:
stage: deploy
tags:
- uberserver
script:
- df -H /
- |
ssh -T "$SSH_COMMAND" /bin/bash -s << EOT
cd uberserver/
git checkout master
git fetch --all
git reset --hard HEAD
git status
git pull
df -H /
sh ci_to_prod.sh
EOT
dependencies:
- tests
environment:
name: deploy
only:
- master