/
.gitlab-ci.yml
120 lines (110 loc) · 3.22 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
stages:
- test
- analyze
- deploy
variables:
# .env Settings
## DB Connection
DB_DATABASE: homestead
DB_USERNAME: homestead
DB_PASSWORD: secret
## Other
CACHE_DRIVER: array
SESSION_DRIVER: array
MAIL_DRIVER: log
# MySQL Service
MYSQL_ROOT_PASSWORD: root_password
MYSQL_DATABASE: $DB_DATABASE
MYSQL_USER: $DB_USERNAME
MYSQL_PASSWORD: $DB_PASSWORD
# Postgres Service
POSTGRES_DB: $DB_DATABASE
POSTGRES_USER: $DB_USERNAME
POSTGRES_PASSWORD: $DB_PASSWORD
.job_template: &job_template
stage: test
services:
- mysql:5.7
variables:
DB_CONNECTION: mysql
DB_HOST: mysql
DB_PORT: '3306'
cache: # Speed up builds
key: $CI_BUILD_REF_NAME
paths:
- vendor
- node_modules
script:
# Config php
- echo "short_open_tag = Off" | sudo tee /usr/local/etc/php/php.ini
- echo "xdebug.mode=coverage" | sudo tee /usr/local/etc/php/conf.d/xdebug.ini
# Install
- composer install --prefer-dist --no-ansi --no-interaction --no-progress --no-scripts
- yarn install
- yarn run dev
- cp .env.example .env
- php artisan key:generate
- php artisan config:clear
- php artisan migrate:refresh
# Test
- ./vendor/phpunit/phpunit/phpunit
--coverage-text
--coverage-html=coverage
--coverage-clover phpunit.coverage.xml
--log-junit phpunit.report.xml
--stderr --colors=never
artifacts:
paths:
- coverage/
- phpunit.report.xml
- phpunit.coverage.xml
- storage/logs # for debugging
expire_in: 7 days
when: always
php7.4:mysql:5.7:
<<: *job_template
image: edbizarro/gitlab-ci-pipeline-php:7.4
outdated-composer:
stage: analyze
image: edbizarro/gitlab-ci-pipeline-php:7.4-alpine
dependencies: []
allow_failure: true
cache: # Speed up builds
key: "$CI_COMMIT_REF_NAME-$CI_JOB_NAME"
paths:
- vendor
script:
# 先升級到最新 (> 2.0.12) 才支援新版的 Github token
- sudo composer self-update
- composer config github-oauth.github.com $COMPOSER_GITHUB_TOKEN
- composer install --prefer-dist --no-ansi --no-interaction --no-progress --no-scripts
- composer outdated --ansi
- curl -OL https://github.com/fabpot/local-php-security-checker/releases/download/v1.0.0/local-php-security-checker_1.0.0_linux_amd64
- chmod +x local-php-security-checker_1.0.0_linux_amd64
- ./local-php-security-checker_1.0.0_linux_amd64
outdated-yarn:
stage: analyze
image: edbizarro/gitlab-ci-pipeline-php:7.4-alpine
dependencies: []
allow_failure: true
script:
- yarn outdated --color || true
- yarn audit --color
deploy_production:
tags:
- FCU-IDC
stage: deploy
image: danny50610/gitlab-ci-laravel-deploy
dependencies: []
script:
- eval $(ssh-agent -s)
- ssh-add <(echo "$SSH_PRIVATE_KEY")
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
- ~/.composer/vendor/bin/envoy --version
- ~/.composer/vendor/bin/envoy run deploy --ansi --server="$production_server_ip"
environment:
name: production
url: https://checkin.hackersir.org/
when: manual
only:
- '2022'