forked from agenciafmd/starter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
_.gitlab-ci.yml
167 lines (156 loc) · 3.93 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
164
165
166
167
#https://www.talvbansal.me/blog/in-depth-gitlab-ci-cd-with-laravel-apps/
#https://github.com/Geovica/Laravel-Gitlab-CI-CD-setup/blob/master/.gitlab-ci.yml
image: edbizarro/gitlab-ci-pipeline-php:8.0
stages:
- preparation
- optimization
- syntax
- testing
- deploy
.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
git config --global user.email "[email protected]"
git config --global user.name "Waste Allocation Load Lifter Earth-Class"
[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
cache:
key: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
composer:
stage: preparation
only:
refs:
- develop
changes:
- composer.lock
- "**/*.php"
script:
- composer install --prefer-dist --no-ansi --no-interaction --no-progress --no-scripts --no-suggest
- cp .env.ci-cd .env
- php artisan key:generate
artifacts:
paths:
- vendor/
- .env
expire_in: 1 day
when: always
cache:
paths:
- vendor/
npm:
stage: preparation
only:
refs:
- develop
changes:
- package-lock.json
- resources/**/*
before_script:
- sudo apt-get update
- sudo apt-get install -y bzip2
script:
- npm install
artifacts:
paths:
- node_modules/
expire_in: 1 day
when: always
cache:
paths:
- node_modules/
#npm-run-prod:
# stage: optimization
# only:
# refs:
# - develop
# changes:
# - package-lock.json
# - resources/**/*
# dependencies:
# - composer
# - npm
# before_script:
# - sudo apt-get update
# - sudo apt-get install -y gconf-service libasound2 libatk1.0-0 libc6 libcairo2
# libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0
# libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6
# libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6
# libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1
# libnss3 lsb-release xdg-utils wget
# script:
# - php artisan serve &
# - sleep 5
# - npm run prod
# artifacts:
# paths:
# - public/css/
# - public/js/
# - public/mix-manifest.json
# expire_in: 1 day
# when: always
php-cs-fixer:
stage: syntax
only:
refs:
- develop
changes:
- composer.lock
- "**/*.php"
script:
- ./vendor/bin/php-cs-fixer fix --config=.php_cs.php --verbose --diff
artifacts:
paths:
- packages/
expire_in: 1 day
when: always
phpstan:
stage: testing
only:
refs:
- develop
changes:
- composer.lock
- "**/*.php"
script:
- ./vendor/bin/phpstan analyse --memory-limit=2G
- touch database/database.sqlite
wall-e:
stage: deploy
only:
refs:
- develop
changes:
- composer.lock
- "**/*.php"
- package-lock.json
- resources/**/*
variables:
HOST_INTERNO: "$HOST_INTERNO"
HOST_PLESK: "$HOST_PLESK"
SLACK_BOT: "$SLACK_BOT"
script:
- *init_ssh
- git add .
- git commit -m "feat(wall-e) commita o nrp e/ou php-cs-fix $CI_COMMIT_SHORT_SHA [skip ci]" || echo "Nenhuma alteração!"
- git remote rm origin && git remote add origin [email protected]:$CI_PROJECT_PATH.git
- git push origin HEAD:$CI_COMMIT_REF_NAME
# - ./vendor/bin/envoy run deploy
#wall-e-prod:
# stage: deploy
# only:
# - master
# variables:
# HOST_INTERNO: "$HOST_INTERNO"
# HOST_PLESK: "$HOST_PLESK"
# SLACK_BOT: "$SLACK_BOT"
# script:
# - *init_ssh
# - git remote rm origin && git remote add origin [email protected]:$CI_PROJECT_PATH.git
# - git branch develop
# - git pull origin develop
# - git merge --no-ff develop
# - git push origin HEAD:$CI_COMMIT_REF_NAME
# - ./vendor/bin/envoy run deploy --branch=master
# when: delayed
# start_in: 10 minutes