-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
107 lines (95 loc) · 3.05 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
stages:
- build
- test
- release
- deploy
variables:
CONTAINER_TEST_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
CONTAINER_RELEASE_IMAGE: $CI_REGISTRY_IMAGE:latest
build-image:
stage: build
image: docker:git
services:
- docker:dind
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
script:
- docker build -t $CONTAINER_TEST_IMAGE .
- docker push $CONTAINER_TEST_IMAGE
cache:
- key:
files:
- composer.lock
prefix: $CI_COMMIT_REF_SLUG
paths:
- vendor/
policy: push
test:
stage: test
image: $CONTAINER_TEST_IMAGE
services:
- name: mysql:8.0
alias: mysql
variables:
XDEBUG_MODE: coverage
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: pret-a-oser
DATABASE_URL: 'mysql://root:root@mysql:3306/pret-a-oser'
JWT_SECRET_KEY: $JWT_SECRET_KEY
JWT_PUBLIC_KEY: $JWT_PUBLIC_KEY
JWT_PASSPHRASE: $JWT_PASSPHRASE
before_script:
- composer install
# - symfony console doctrine:database:drop --force --env=test
- symfony console doctrine:database:create --env=test
- symfony console doctrine:schema:create --env=test --no-interaction
- symfony serve -d --no-tls
script:
# - php bin/phpunit --configuration phpunit.xml.dist --coverage-text --colors=never
- php bin/phpunit --log-junit report.xml
allow_failure: false
artifacts:
when: always
reports:
junit: report.xml
coverage: '/\d+\.\d+/'
cache:
- key:
files:
- composer.lock
prefix: $CI_COMMIT_REF_SLUG
paths:
- vendor/
policy: pull
# release-image:
# stage: release
# script:
# - docker pull $CONTAINER_TEST_IMAGE
# - docker tag $CONTAINER_TEST_IMAGE $CONTAINER_RELEASE_IMAGE
# - docker push $CONTAINER_RELEASE_IMAGE
# only:
# - main
# deploy-to-staging:
# tags:
# - shell
# stage: deploy
# environment:
# name: staging
# script:
# - ssh $SERVER_USER@$SERVER_HOST "rm -rf ~/public_html/pret-a-oser/staging/pret-a-oser-api/* && ls -la ~/public_html/pret-a-oser/staging/pret-a-oser-api"
# - ssh $SERVER_USER@$SERVER_HOST "cd ~/public_html/pret-a-oser/staging/pret-a-oser-api && git clone --depth 1 --branch $CI_COMMIT_REF_NAME $CI_REPOSITORY_URL . && git log --oneline "
# - ssh -p22 $SERVER_USER@$SERVER_HOST "cd ~/public_html/pret-a-oser/staging/pret-a-oser-api && composer install --no-dev"
# except:
# - main
# deploy-to-production:
# tags:
# - shell
# stage: deploy
# environment:
# name: production
# script:
# - ssh $SERVER_USER@$SERVER_HOST "rm -rf ~/public_html/pret-a-oser/production/pret-a-oser-api/* && ls -la ~/public_html/pret-a-oser/production/pret-a-oser-api"
# - ssh $SERVER_USER@$SERVER_HOST "cd ~/public_html/pret-a-oser/production/pret-a-oser-api && git clone --depth 1 --branch $CI_COMMIT_REF_NAME $CI_REPOSITORY_URL . && git log --oneline "
# - ssh -p22 $SERVER_USER@$SERVER_HOST "cd ~/public_html/pret-a-oser/production/pret-a-oser-api && composer install --no-dev"
# only:
# - main