-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
116 lines (102 loc) · 3.49 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
109
110
111
112
113
114
115
116
image: infocorpjr/laravel
stages:
- build
- test
- deploy
before_script:
- export TERM=linux
- export DEBIAN_FRONTEND=noninteractive
################################################################################
# BUILD STAGE #
################################################################################
build:
stage: build
cache:
key: ${CI_COMMIT_REF_SLUG}-environment
paths:
- tests/Browser/screenshots/
- vendor/
- node_modules/
- .env
artifacts:
expire_in: 2h
paths:
- tests/Browser/screenshots/
- vendor/
- node_modules/
- .env
script:
- composer install --prefer-dist --no-ansi --no-interaction --no-progress --no-scripts
- npm install
- npm run prod
- cp .env.example .env
- php artisan key:generate
- chown www-data:www-data storage -R
################################################################################
# TEST STAGE #
################################################################################
codestyle:
stage: test
script:
# Verificação do padrão PSR2.
- vendor/bin/phpcs --standard=PSR2 --extensions=php app
# IMPORTANTE! Testa a migração do banco do banco de dados (NO SQLITE)
database:
stage: test
script:
- touch database/database.sqlite
- php artisan migrate --seed
phpunit:
stage: test
script:
- touch database/database.sqlite
- vendor/bin/phpunit --coverage-text --colors=never
# DESATIVADO!
.e2e:
stage: test
script:
- rm -R /var/www
- ln -s $CI_PROJECT_DIR /var/www
- touch database/database.sqlite
- php artisan migrate
- /etc/init.d/apache2 start
- php artisan dusk
################################################################################
# DEPLOY STAGE #
################################################################################
.init_ssh: &init_ssh |
eval $(ssh-agent -s)
echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
mkdir -p ~/.ssh
chmod 700 ~/.ssh
ssh-keyscan "$SSH_KNOWN_HOSTS" >> ~/.ssh/known_hosts
chmod 644 ~/.ssh/known_hosts
deploy_review:
stage: deploy
script:
- *init_ssh
# Adiciona os valores das variáveis de ambiente em um arquivo ...
- echo "SLACK_WEBHOOK=$SLACK_WEBHOOK MAIL_USERNAME=$MAIL_USERNAME MAIL_PASSWORD=$MAIL_PASSWORD " | tee deploy/vars.sh > /dev/null
# Junta o arquivo de variáveis de ambiente e o arquivo de instalação e configuração da aplicação
- cat deploy/vars.sh deploy/deploy.sh > deploy/preview.sh
- ssh -T suporte@"$SSH_KNOWN_HOSTS" < deploy/preview.sh
environment:
name: review
url: http://review5.infocorpjr.com
only:
- master
deploy_production:
stage: deploy
script:
- *init_ssh
# Adiciona os valores das variáveis de ambiente em um arquivo ...
- echo "SLACK_WEBHOOK=$SLACK_WEBHOOK MAIL_USERNAME=$MAIL_USERNAME MAIL_PASSWORD=$MAIL_PASSWORD ADMIN_EMAIL=$ADMIN_EMAIL ADMIN_PASSWORD=$ADMIN_PASSWORD" | tee deploy/vars-production.sh
# Junta o arquivo de variáveis e o arquivo de para build da aplicação ...
- cat deploy/vars-production.sh deploy/deploy-production.sh > deploy/production.sh > /dev/null
- ssh -T suporte@"$SSH_KNOWN_HOSTS" < deploy/production.sh
environment:
name: production
url: http://maratona.infocorpjr.com
when: manual
only:
- production