-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy path.gitlab-ci.yml
97 lines (85 loc) · 2.07 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
image: ruby:2.7.1-slim-buster
stages:
- Testing Application
- Deploy Staging
- Deploy Production
### VARIABLES ###
variables:
ENV_STAGING: "staging"
ENV_PRODUCTION: "production"
MYSQL_DATABASE: "laravel"
MYSQL_ROOT_PASSWORD: "secret"
MYSQL_PASSWORD: "secret"
.preparation: &preparation
### SETUP SSH ###
- apt-get update -qq
- apt-get install -qq git build-essential
- 'which ssh-agent || ( apt-get install -qq openssh-client )'
- mkdir -p ~/.ssh
- echo "${MYAPP_SSH_PRIVATE_KEY}" | tr -d '\r' > ~/.ssh/id_rsa
- echo "${MYAPP_KNOWN_HOSTS}" | tr -d '\r' > ~/.ssh/known_hosts
- chmod 700 ~/.ssh/id_rsa
- eval "$(ssh-agent -s)"
- ssh-add ~/.ssh/id_rsa
- ssh-keyscan -H 'gitlab.com' >> ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
### INSTALL LIBRARY ###
- gem install bundler
- bundle install
.run_test: &run_test
- cp src/.env.pipeline.gitlab src/.env
- make fixing-cache
- make composer-install-cicd
- make key-generate
- make composer-dumpautoload
- make run-migrate-all
- make clear-all
.run_staging: &run_staging
- make deploy-staging
.run_production: &run_production
- make deploy-production
.synchronize_staging: &synchronize_staging
- make synchronize-staging
.synchronize_production: &synchronize_production
- make synchronize-production
unit_test_staging:
image: edbizarro/gitlab-ci-pipeline-php:7.4-alpine
environment: ${ENV_STAGING}
stage: Testing Application
services:
- mariadb:10.3.11
script:
- *run_test
only:
- dev-staging
unit_test_production:
image: edbizarro/gitlab-ci-pipeline-php:7.4-alpine
environment: ${ENV_PRODUCTION}
stage: Testing Application
services:
- mariadb:10.3.11
script:
- *run_test
only:
- dev-master
deploy_staging:
environment: ${ENV_STAGING}
stage: Deploy Staging
before_script:
- *preparation
script:
- *run_staging
when: manual
only:
- dev-master
- dev-staging
deploy_production:
environment: ${ENV_PRODUCTION}
stage: Deploy Production
before_script:
- *preparation
script:
- *run_production
when: manual
only:
- dev-master