-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
73 lines (66 loc) · 1.64 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
# usermod -aG docker gitlab-runner
stages:
- unit
- build
- deploy
variables:
PROJECT_NAME: hyperf
REGISTRY_URL: registry-docker.org
GIT_SUBMODULE_STRATEGY: recursive
unit:
stage: unit
image: hyperf/docker-ci:latest
resource_group: $CI_PROJECT_NAME
variables:
DOCKER_TLS_CERTDIR: ""
DOCKER_DRIVER: overlay2
before_script:
- cp .env.example .env
script:
- APP_ENV=test docker-compose up -d --remove-orphans --build
- docker exec $(basename $(pwd))_hyperf_1 composer install
- docker exec $(basename $(pwd))_hyperf_1 composer analyse
- docker exec $(basename $(pwd))_hyperf_1 vendor/bin/php-cs-fixer fix --dry-run
- docker exec $(basename $(pwd))_hyperf_1 composer test
after_script:
- docker-compose down
tags:
- unit
build_test_docker:
stage: build
script:
- docker build . -t $PROJECT_NAME
- docker tag $PROJECT_NAME $REGISTRY_URL/$PROJECT_NAME:test
- docker push $REGISTRY_URL/$PROJECT_NAME:test
only:
- test
tags:
- builder
deploy_test_docker:
stage: deploy
script:
- docker stack deploy -c deploy.test.yml --with-registry-auth $PROJECT_NAME
only:
- test
tags:
- test
build_docker:
stage: build
script:
- docker build . -t $PROJECT_NAME
- docker tag $PROJECT_NAME $REGISTRY_URL/$PROJECT_NAME:$CI_COMMIT_REF_NAME
- docker tag $PROJECT_NAME $REGISTRY_URL/$PROJECT_NAME:latest
- docker push $REGISTRY_URL/$PROJECT_NAME:$CI_COMMIT_REF_NAME
- docker push $REGISTRY_URL/$PROJECT_NAME:latest
only:
- tags
tags:
- builder
deploy_docker:
stage: deploy
script:
- echo SUCCESS
only:
- tags
tags:
- builder