-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
111 lines (103 loc) · 3.69 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
stages:
- test
- stage
- deploy
before_script:
- echo "deb http://ftp.debian.org/debian jessie-backports main" >> /etc/apt/sources.list
- echo "deb http://ftp.debian.org/debian jessie main non-free contrib" >> /etc/apt/sources.list
- apt-get update -yqq && apt-get install -yqq ffmpeg zip unzip python-software-properties
- curl -sL https://deb.nodesource.com/setup_9.x | bash -
- apt-get install nodejs
- pecl update-channels
- pecl install -f xdebug-2.5.5
# Install PHP extensions
- docker-php-ext-install pdo_mysql
- docker-php-ext-enable xdebug
# Install and run Composer
- curl -sS https://getcomposer.org/installer | php
- cd src
- rm -f composer.lock
- php ../composer.phar require --no-update phpunit/phpunit:^5.7
- php ../composer.phar install --no-dev
# Set any variables we need
variables:
# Configure mysql environment variables (https://hub.docker.com/r/_/mysql/)
MYSQL_DATABASE: podtube
MYSQL_ROOT_PASSWORD: root
# Run our tests
# If Xdebug was installed you can generate a coverage report and see code coverage metrics.
test:7.0:
stage: test
# This file is a template, and might need editing before it works on your project.
# Select image from https://hub.docker.com/_/php/
image: php:7.0
services:
- mysql:5.7
script:
- vendor/bin/phpunit --configuration ../phpunit.xml --coverage-text --colors=never
test:5.6:
stage: test
# This file is a template, and might need editing before it works on your project.
# Select image from https://hub.docker.com/_/php/
image: php:5.6
services:
- mysql:5.7
script:
- vendor/bin/phpunit --configuration ../phpunit.xml --coverage-text --colors=never
test:latest:
stage: test
image: php:latest
services:
- mysql:5.7
before_script:
- echo "deb http://ftp.debian.org/debian jessie-backports main" >> /etc/apt/sources.list
- echo "deb http://ftp.debian.org/debian jessie main non-free contrib" >> /etc/apt/sources.list
- apt-get update -yqq && apt-get install -yqq ffmpeg zip unzip python-software-properties
- curl -sL https://deb.nodesource.com/setup_9.x | bash -
- apt-get install nodejs
- pecl update-channels
- pecl install -f xdebug
# Install PHP extensions
- docker-php-ext-install pdo_mysql
- docker-php-ext-enable xdebug
# Install and run Composer
- curl -sS https://getcomposer.org/installer | php
- cd src
- rm -f composer.lock
- php ../composer.phar require --no-update phpunit/phpunit:^5.7
- php ../composer.phar install --no-dev
script:
- vendor/bin/phpunit --configuration ../phpunit.xml --coverage-text --colors=never
stage:
stage: stage
environment:
name: Staging
before_script:
- which ssh-agent || ( apt-get update -yqq && apt-get install openssh-client -yqq )
- eval $(ssh-agent -s)
- ssh-add <(echo "$SSH_PRIVATE_KEY" | base64 -d)
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- ssh-keyscan -H $DEPLOY_IP >> ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
script:
- scp -r src/* gitlab@$DEPLOY_IP:/var/www/html/ytpod-beta/
- ssh gitlab@$DEPLOY_IP -tt "chown -R gitlab:www-data /var/www/html/ytpod-beta/* || true"
deploy:
stage: deploy
before_script:
- which ssh-agent || ( apt-get update -yqq && apt-get install openssh-client -yqq )
- eval $(ssh-agent -s)
- ssh-add <(echo "$SSH_PRIVATE_KEY" | base64 -d)
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- ssh-keyscan -H $DEPLOY_IP >> ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
script:
- scp -r src/* gitlab@$DEPLOY_IP:/var/www/html/ytpod/
- ssh gitlab@$DEPLOY_IP -tt "chown -R gitlab:www-data /var/www/html/ytpod/* || true"
environment:
name: Production
when: manual
only:
- master