-
Notifications
You must be signed in to change notification settings - Fork 61
/
.gitlab-ci.yml.example.yaml
54 lines (54 loc) · 1.46 KB
/
.gitlab-ci.yml.example.yaml
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
stages:
- pull_code_test
- pull_code_production
- install_deps
- test
- build
- deploy_test
- deploy_production
variables:
PHP_FPM_CONTAINER: lnmp-php-fpm
WORK_DIR: /usr/share/nginx/html/
PROJECT: laravel-demo
GIT_DIR: /mnt/lnmp-docker
# 拉取代码
pull_code_test:
stage: pull_code_test
only:
- develop
script:
- cd ${GIT_DIR}/${PROJECT}
- git pull origin develop
pull_code_production:
stage: pull_code_production
only:
- master
script:
- cd ${GIT_DIR}/${PROJECT}
- git pull origin master
# 安装依赖
install_deps:
stage: install_deps
script:
- docker exec -w ${WORK_DIR}/${PROJECT} ${PHP_FPM_CONTAINER} composer install
build:
stage: build
script:
# Run migrations
- docker exec -w ${WORK_DIR}/${PROJECT} ${PHP_FPM_CONTAINER} php artisan migrate
# Cache clearing
- docker exec -w ${WORK_DIR}/${PROJECT} ${PHP_FPM_CONTAINER} php artisan cache:clear
# Create a cache file for faster configuration loading
- docker exec -w ${WORK_DIR}/${PROJECT} ${PHP_FPM_CONTAINER} php artisan config:cache
# Create a route cache file for faster route registration
- docker exec -w ${WORK_DIR}/${PROJECT} ${PHP_FPM_CONTAINER} php artisan route:clear
deploy_test:
stage: deploy_test
script:
- cd ${GIT_DIR}
- docker-compose down && docker-compose build && docker-compose up -d
deploy_production:
stage: deploy_production
script:
- cd ${GIT_DIR}
- docker-compose restart