-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.gitlab-ci.yml
163 lines (151 loc) · 4.01 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
stages:
- preparation
- building
- testing
- security
- deploy
# Variables
variables:
MYSQL_ROOT_PASSWORD: root
MYSQL_USER: homestead
MYSQL_PASSWORD: secret
MYSQL_DATABASE: homestead
DB_HOST: mysql
REDIS_HOST: redis
REDIS_PORT: 6379
cache:
key: "$CI_COMMIT_REF_NAME"
composer:
stage: preparation
services:
- mysql:5.7
- redis:latest
image: edbizarro/gitlab-ci-pipeline-php:latest
script:
- php -v
- composer install --prefer-dist --no-ansi --no-interaction --no-progress --no-scripts
- cp .env.example .env
- php artisan key:generate
artifacts:
paths:
- vendor/
- .env
expire_in: 1 days
when: always
cache:
paths:
- vendor/
npm:
stage: preparation
image: edbizarro/gitlab-ci-pipeline-php:latest
script:
- npm install
artifacts:
paths:
- node_modules/
expire_in: 1 days
when: always
cache:
paths:
- node_modules/
build-assets:
stage: building
image: edbizarro/gitlab-ci-pipeline-php:7.2
# Download the artifacts for these jobs
dependencies:
- composer
- npm
script:
- npm run production --progress false
artifacts:
paths:
- public/css/
- public/js/
- public/fonts/
- public/mix-manifest.json
- public/images/
expire_in: 1 days
when: always
db-seeding:
stage: building
services:
- mysql:5.7
- redis:latest
image: edbizarro/gitlab-ci-pipeline-php:latest
# Download the artifacts for these jobs
dependencies:
- composer
- npm
script:
- php artisan migrate:fresh --seed
artifacts:
paths:
- ./storage/logs # for debugging
expire_in: 1 days
when: on_failure
phpunit:
stage: testing
services:
- mysql:5.7
- redis:latest
image: edbizarro/gitlab-ci-pipeline-php:latest
# Download the artifacts for these jobs
dependencies:
- build-assets
- composer
- db-seeding
script:
- php -v
- sudo cp /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini /usr/local/etc/php/conf.d/docker-php-ext-xdebug.bak
- echo "" | sudo tee /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
- ./vendor/phpunit/phpunit/phpunit --version
- php -d short_open_tag=off ./vendor/phpunit/phpunit/phpunit -v --colors=never --stderr
- sudo cp /usr/local/etc/php/conf.d/docker-php-ext-xdebug.bak /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
artifacts:
paths:
- ./storage/logs # for debugging
expire_in: 1 days
when: on_failure
codestyle:
stage: testing
image: lorisleiva/laravel-docker
script:
- phpcs --extensions=php app
dependencies: []
phpcpd:
stage: testing
image: edbizarro/gitlab-ci-pipeline-php:latest
script:
- test -f phpcpd.phar || curl -L https://phar.phpunit.de/phpcpd.phar -o phpcpd.phar
- php phpcpd.phar app/ --min-lines=50
dependencies: []
cache:
paths:
- phpcpd.phar
sensiolabs:
stage: security
image: edbizarro/gitlab-ci-pipeline-php:latest
script:
- test -d security-checker || git clone https://github.com/sensiolabs/security-checker.git
- cd security-checker
- composer install
- php security-checker security:check ../composer.lock
dependencies: []
cache:
paths:
- security-checker/
deployment:
stage: deploy
image: edbizarro/gitlab-ci-pipeline-php:latest
environment:
name: production
url: https://salvemundi.nl
script:
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
- eval $(ssh-agent -s)
- ssh-add <(echo "$DEPLOYER_KEY")
- mkdir -p ~/.ssh
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
- ssh [email protected] "cd /var/www/html/salvemundi.nl/ && php artisan down && git fetch && git checkout master && git reset --hard && git clean -f && git pull && composer install && npm install --progress false && sudo npm run production --progress false && php artisan config:cache && php artisan route:cache && php artisan migrate --force && php artisan up"
only:
- master