2017-09-25 00:03:22 +02:00
|
|
|
image: php
|
|
|
|
|
|
|
|
cache:
|
|
|
|
paths:
|
2018-08-03 05:09:11 +02:00
|
|
|
- .composer
|
2017-09-25 00:03:22 +02:00
|
|
|
|
|
|
|
services:
|
2017-11-25 10:53:50 +01:00
|
|
|
- mariadb:10.2
|
2017-09-25 00:03:22 +02:00
|
|
|
|
|
|
|
variables:
|
|
|
|
MYSQL_DATABASE: engelsystem
|
|
|
|
MYSQL_USER: engel
|
|
|
|
MYSQL_PASSWORD: engelsystem
|
2017-11-25 10:53:50 +01:00
|
|
|
MYSQL_HOST: mariadb
|
2017-09-25 00:03:22 +02:00
|
|
|
MYSQL_RANDOM_ROOT_PASSWORD: "yes"
|
2017-11-29 14:35:59 +01:00
|
|
|
COMPOSER_HOME: .composer
|
2017-09-25 00:03:22 +02:00
|
|
|
|
|
|
|
before_script:
|
2017-10-22 17:04:07 +02:00
|
|
|
# Fix permissions after gitlab messed them up
|
2017-11-29 14:35:59 +01:00
|
|
|
- &before_fix_permissions |-
|
|
|
|
find . -type f -exec chmod 644 {} \;
|
|
|
|
find . -type d -exec chmod 755 {} \;
|
2017-09-25 00:03:22 +02:00
|
|
|
# Install required Packages
|
2017-11-29 14:35:59 +01:00
|
|
|
- &before_install_packages |-
|
|
|
|
apt update -yqq
|
|
|
|
apt install -yqq git unzip
|
|
|
|
docker-php-ext-install pdo pdo_mysql gettext
|
2017-09-25 00:03:22 +02:00
|
|
|
# Install xdebug
|
2017-11-29 14:35:59 +01:00
|
|
|
- &before_install_xdebug |-
|
|
|
|
pecl install xdebug
|
|
|
|
docker-php-ext-enable xdebug
|
2017-09-25 00:03:22 +02:00
|
|
|
# MySQL DB
|
2017-11-29 14:35:59 +01:00
|
|
|
- &before_setup_mysql |-
|
|
|
|
apt install -yqq mariadb-client
|
|
|
|
mysql -h "$MYSQL_HOST" -u "$MYSQL_USER" -p"$MYSQL_PASSWORD" "$MYSQL_DATABASE" < db/install.sql
|
|
|
|
mysql -h "$MYSQL_HOST" -u "$MYSQL_USER" -p"$MYSQL_PASSWORD" "$MYSQL_DATABASE" < db/update.sql
|
2017-09-25 00:03:22 +02:00
|
|
|
# Install Composer
|
2017-11-29 14:35:59 +01:00
|
|
|
- &before_install_composer |-
|
|
|
|
curl -sS https://getcomposer.org/installer | php -- --no-ansi --install-dir /usr/local/bin/ --filename composer
|
2018-08-03 05:09:11 +02:00
|
|
|
composer --no-ansi install
|
|
|
|
# Install Node.js and Yarn
|
|
|
|
- &before_install_yarn |-
|
|
|
|
apt -yqq install gnupg2 apt-transport-https
|
|
|
|
curl -sL https://deb.nodesource.com/setup_8.x | bash -
|
|
|
|
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
|
|
|
|
echo "deb https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list
|
|
|
|
apt -yqq update && apt -yqq install nodejs yarn
|
|
|
|
yarn install
|
|
|
|
yarn build
|
2017-09-25 00:03:22 +02:00
|
|
|
|
|
|
|
.test_template: &test_definition
|
2017-11-29 14:35:59 +01:00
|
|
|
stage: test
|
2017-09-25 00:03:22 +02:00
|
|
|
artifacts:
|
2018-08-04 21:26:33 +02:00
|
|
|
name: "${CI_JOB_NAME}_${CI_JOB_ID}"
|
2017-09-25 00:03:22 +02:00
|
|
|
expire_in: 1 week
|
|
|
|
paths:
|
|
|
|
- ./coverage/
|
|
|
|
coverage: '/^\s*Lines:\s*(\d+(?:\.\d+)?%)/'
|
|
|
|
script: vendor/bin/phpunit --colors=never --coverage-text --coverage-html ./coverage/
|
|
|
|
|
|
|
|
test:7.0:
|
|
|
|
<<: *test_definition
|
2017-11-29 14:35:59 +01:00
|
|
|
image: php:7.0
|
2017-09-25 00:03:22 +02:00
|
|
|
|
|
|
|
test:7.1:
|
|
|
|
<<: *test_definition
|
2017-11-29 14:35:59 +01:00
|
|
|
image: php:7.1
|
2017-10-22 17:04:07 +02:00
|
|
|
|
2017-11-29 14:35:59 +01:00
|
|
|
.deploy_template: &deploy_definition
|
|
|
|
services: []
|
2017-10-22 17:04:07 +02:00
|
|
|
stage: deploy
|
|
|
|
only:
|
2018-08-03 05:09:11 +02:00
|
|
|
- master
|
2017-11-29 14:35:59 +01:00
|
|
|
before_script:
|
|
|
|
- *before_fix_permissions
|
|
|
|
- *before_install_packages
|
|
|
|
- *before_install_composer
|
2018-08-03 05:09:11 +02:00
|
|
|
- *before_install_yarn
|
2017-11-29 14:35:59 +01:00
|
|
|
|
|
|
|
.deploy_template_script:
|
|
|
|
# Configure SSH
|
|
|
|
- &deployment_ssh |-
|
|
|
|
mkdir -p ~/.ssh
|
|
|
|
echo "$SSH_PRIVATE_KEY" | sed -e 's/\r//g' > ~/.ssh/id_ed25519
|
|
|
|
chmod 600 ~/.ssh/id_ed25519
|
|
|
|
|
|
|
|
# Install project and dependencies
|
|
|
|
- &deployment_dependencies |-
|
2018-08-07 16:47:47 +02:00
|
|
|
chmod +x ./bin/deploy.sh
|
2017-11-29 14:35:59 +01:00
|
|
|
apt update && apt install -yqq rsync openssh-client
|
2018-08-03 05:09:11 +02:00
|
|
|
composer --no-ansi install --no-dev
|
|
|
|
composer --no-ansi dump-autoload --optimize
|
2017-11-29 14:35:59 +01:00
|
|
|
|
2018-08-04 21:26:33 +02:00
|
|
|
build_release_file:
|
|
|
|
<<: *deploy_definition
|
|
|
|
artifacts:
|
|
|
|
name: "release_${CI_COMMIT_REF_SLUG}_${CI_JOB_ID}_${CI_COMMIT_SHA}"
|
|
|
|
expire_in: 1 week
|
|
|
|
paths:
|
|
|
|
- ./release/
|
|
|
|
script:
|
|
|
|
- *deployment_dependencies
|
|
|
|
- rsync -vAax --exclude '.git*' --exclude .composer/ --exclude coverage/ --exclude node_modules/ --exclude release/ ./ release/
|
|
|
|
|
2017-11-29 14:35:59 +01:00
|
|
|
deploy_staging:
|
|
|
|
<<: *deploy_definition
|
|
|
|
environment:
|
|
|
|
name: staging
|
2017-10-22 17:04:07 +02:00
|
|
|
script:
|
2017-11-29 14:35:59 +01:00
|
|
|
# Check if deployment variables where set
|
2017-10-22 17:04:07 +02:00
|
|
|
- |-
|
2017-11-29 14:35:59 +01:00
|
|
|
if [ -z "${SSH_PRIVATE_KEY}" ] || [ -z "${STAGING_REMOTE}" ] || [ -z "${STAGING_REMOTE_PATH}" ]; then
|
2017-10-22 17:04:07 +02:00
|
|
|
echo "Skipping deployment";
|
|
|
|
exit
|
|
|
|
fi
|
2017-11-29 14:35:59 +01:00
|
|
|
- *deployment_ssh
|
|
|
|
- *deployment_dependencies
|
|
|
|
# Deploy to server
|
2018-08-07 16:47:47 +02:00
|
|
|
- ./bin/deploy.sh -r "${STAGING_REMOTE}" -p "${STAGING_REMOTE_PATH}" -i "${CI_JOB_ID}-${CI_COMMIT_SHA}"
|
2017-10-22 17:04:07 +02:00
|
|
|
|
2017-11-29 14:35:59 +01:00
|
|
|
deploy_production:
|
|
|
|
<<: *deploy_definition
|
|
|
|
environment:
|
|
|
|
name: production
|
|
|
|
when: manual
|
|
|
|
script:
|
|
|
|
# Check if deployment variables where set
|
|
|
|
- |-
|
|
|
|
if [ -z "${SSH_PRIVATE_KEY}" ] || [ -z "${PRODUCTION_REMOTE}" ] || [ -z "${PRODUCTION_REMOTE_PATH}" ]; then
|
|
|
|
echo "Skipping deployment";
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
- *deployment_ssh
|
|
|
|
- *deployment_dependencies
|
|
|
|
# Deploy to server
|
2018-08-07 16:47:47 +02:00
|
|
|
- ./bin/deploy.sh -r "${PRODUCTION_REMOTE}" -p "${PRODUCTION_REMOTE_PATH}" -i "${CI_JOB_ID}-${CI_COMMIT_SHA}"
|