-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
.gitlab-ci.yml
93 lines (81 loc) · 2.14 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
image: helldar/laravel-gitlab-ci:stable
services:
- mysql:latest
- redis:latest
variables:
APP_NAME: "${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}"
MYSQL_DATABASE: database_name
MYSQL_ROOT_PASSWORD: secret
GITLAB_HOST: 123.123.123.123
GITLAB_PORT: "22"
PRODUCTION_HOST: 123.123.123.123
.init_ssh: &init_ssh |
mkdir -p ~/.ssh
chmod 700 ~/.ssh
printf "Host $GITLAB_HOST\n\tHostname $GITLAB_HOST\n\tPort $GITLAB_PORT\n\tUser git\n\tIdentityFile ~/.ssh/id_rsa\n\n" >> ~/.ssh/config
chmod 644 ~/.ssh/config
echo "$SSH_PRIVATE_KEY" >> ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan $PRODUCTION_HOST >> ~/.ssh/known_hosts
ssh-keyscan $GITLAB_HOST >> ~/.ssh/known_hosts
chmod 644 ~/.ssh/known_hosts
.change_file_permissions: &change_file_permissions |
find . -type f -not -path "./vendor/*" -exec chmod 664 {} \;
find . -type d -not -path "./vendor/*" -exec chmod 775 {} \;
.php_version: &php_version |
php -v
.composer_install: &composer_install |
composer install --prefer-dist --no-interaction --no-progress --no-scripts
composer:
stage: build
only:
- main
- release
script:
- *init_ssh
- *php_version
- *composer_install
- cp .env.testing .env
- php artisan key:generate -vvv
artifacts:
expire_in: 1 week
paths:
- .env
npm:
stage: build
only:
- main
- release
cache:
key: ${CI_PROJECT_NAME}-${CI_COMMIT_REF_SLUG}-yarn
paths:
- node_modules
script:
- npm ci
- npm run build
artifacts:
expire_in: 1 week
paths:
- node_modules
- public/mix-manifest.json
phpunit:
stage: test
only:
- main
- release
dependencies:
- composer
- npm
script:
- *composer_install
- php artisan migrate:fresh --seed --force -vvv
- phpunit --no-coverage -v
production:
stage: deploy
only:
- release
script:
- *init_ssh
- *composer_install
- *change_file_permissions
- dep deploy