This repository has been archived by the owner on Feb 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
.gitlab-ci.yml.example
85 lines (75 loc) · 2.03 KB
/
.gitlab-ci.yml.example
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
stages:
- test
- release
- coverage
.test_template: &test_definition
image: jsphpl/php-node-python:7.4
services:
- postgres:12.1
- redis:5
variables:
POSTGRES_DB: testing
POSTGRES_USER: testing
POSTGRES_PASSWORD: secret
before_script:
- composer install
- php artisan migrate:fresh --seed --env=testing
artifacts:
when: on_failure
name: log
paths:
- storage/logs/laravel.log
test:
<<: *test_definition
stage: test
script:
- ./vendor/bin/phpunit
coverage:
<<: *test_definition
stage: coverage
only:
- master
script:
# Enable xdebug for coverage report
- docker-php-ext-enable xdebug.so
- ./vendor/bin/phpunit --coverage-text
.release_template: &release_definition
stage: release
image: jsphpl/ansible-git
before_script:
# Trust the host key of the deploy target and the gitlab instance
- mkdir -m 700 ~/.ssh
- ssh-keyscan -H YOUR_APP_SERVER_HOSTNAME_GOES_HERE >> ~/.ssh/known_hosts
- ssh-keyscan -H YOUR_GITLAB_SERVER_HOSTNAME_GOES_HERE >> ~/.ssh/known_hosts
# Install private key for deployment
- echo "$DEPLOY_KEY" > ~/.ssh/id_rsa && chmod 0600 ~/.ssh/id_rsa
# Start the ssh agent
- eval $(ssh-agent -s)
- ssh-add ~/.ssh/id_rsa
script:
- git clone YOUR_LARAVAN_PROJECT_GIT_URL_GOES_HERE laravan
- cd laravan
- echo "$VAULT_PASS" > .vault_pass
- ansible-playbook deploy.yml -e env=$ENVIRONMENT_NAME -e app=YOUR_APP_NAME_GOES_HERE
environment:
name: $ENVIRONMENT_NAME
url: https://$TARGET_HOST
release to staging:
<<: *release_definition
only:
- master
variables:
VERSION: $CI_COMMIT_SHA
TARGET_HOST: YOUR_STAGING_HOSTNAME_GOES_HERE
ENVIRONMENT_NAME: staging
DEPLOY_KEY: $STAGING_DEPLOY_KEY
release to production:
<<: *release_definition
only:
- /^v\d+\.\d+\.\d+$/ # version tags (vx.y.z)
when: manual
variables:
VERSION: $CI_COMMIT_TAG
TARGET_HOST: YOUR_PRODUCTION_HOSTNAME_GOES_HERE
ENVIRONMENT_NAME: production
DEPLOY_KEY: $PRODUCTION_DEPLOY_KEY