-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
40 lines (35 loc) · 1.34 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
image: elivz/php
variables:
LIVE_SSH_USER: REPLACE_ME
LIVE_DOMAIN: REPLACE_ME
LIVE_ROOT: /var/www/public
STAGING_SSH_USER: REPLACE_ME
STAGING_DOMAIN: REPLACE_ME
STAGING_ROOT: /var/www/staging_html
EXCLUDED: --exclude 'storage/*' --exclude 'public_html/media' --exclude '.env'
cache:
paths:
- node_modules
- dist/vendor
before_script:
- mkdir -p ~/.ssh
- eval $(ssh-agent -s)
- ssh-add <(echo "$SSH_PRIVATE_KEY")
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
- composer install --no-interaction --no-dev --no-scripts --prefer-dist --no-progress
- yarn --non-interactive --silent --frozen-lockfile
- yarn build
stage_deploy:
stage: deploy
only:
- develop
script:
- rsync -chaz --stats --delete ${EXCLUDED} ./dist/* ${STAGING_SSH_USER}@${STAGING_DOMAIN}:${STAGING_ROOT}
- ssh ${STAGING_SSH_USER}@${STAGING_DOMAIN} "${STAGING_ROOT}/craft migrate/all;${STAGING_ROOT}/craft project-config/sync;${STAGING_ROOT}/craft clear-caches/template-caches"
live_deploy:
stage: deploy
only:
- master
script:
- rsync -chaz --stats --delete ${EXCLUDED} ./dist/* ${LIVE_SSH_USER}@${LIVE_DOMAIN}:${LIVE_ROOT}
- ssh ${LIVE_SSH_USER}@${LIVE_DOMAIN} "${LIVE_ROOT}/craft migrate/all;${LIVE_ROOT}/craft project-config/sync;${LIVE_ROOT}/craft clear-caches/template-caches"