From 5cecd7e9dac609cb533035eb1a96db3ef41a472d Mon Sep 17 00:00:00 2001 From: Too Date: Fri, 22 Jun 2018 14:23:54 +0800 Subject: [PATCH] modify gitlab-ci.yml --- .gitlab-ci.yml | 53 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 38 insertions(+), 15 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 940f9e0f..8b9612b8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,17 +1,40 @@ -before_script: - - bash .gitlab-ci.sh -stages: - - testing - - staging +image: registry.gitlab.com/ciefworldwidesdnbhd/exchange:tag + +services: + - mysql:5.7 + variables: - MYSQL_DATABASE: default - MYSQL_USER: default - MYSQL_PASSWORD: secret - MYSQL_ROOT_PASSWORD: root -unitTesting: - stage: testing - image: php:7.0.13 - services: - - mysql:5.7 + MYSQL_DATABASE: homestead + MYSQL_ROOT_PASSWORD: secret + DB_HOST: mysql + DB_USERNAME: root + +stages: + - test + - deploy + +unit_test: + stage: test script: - - vendor/bin/phpunit --coverage-text --colors=never --configuration phpunit.xml \ No newline at end of file + - cp .env.example .env + - composer install + - php artisan key:generate + - php artisan migrate + - vendor/bin/phpunit + +deploy_production: + stage: deploy + script: + - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )' + - eval $(ssh-agent -s) + - ssh-add <(echo "$SSH_PRIVATE_KEY") + - mkdir -p ~/.ssh + - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config' + + - ~/.composer/vendor/bin/envoy run deploy + environment: + name: production + url: http://192.168.1.1 + when: manual + only: + - master \ No newline at end of file