From 0899a931e4c261a823970ff86b7822a7b83c297b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sun, 20 Nov 2016 22:32:16 +0100 Subject: [PATCH] adding deploy to packagist into pipeline --- .gitlab-ci.yml | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 51432808b..27a959115 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,19 +1,34 @@ -services: - - chill/database:latest - -before_script: - - composer config github-oauth.github.com $GITHUB_TOKEN - - if [ $CI_BUILD_REF_NAME = "1.0" ] ; then export COMPOSER_ROOT_VERSION="1.0-dev"; else export COMPOSER_ROOT_VERSION="dev-master"; fi - - composer install --no-interaction --ignore-platform-reqs - - cp Tests/Fixtures/App/app/config/parameters.gitlab-ci.yml Tests/Fixtures/App/app/config/parameters.yml - - ./console.sh --env=test cache:warmup - - ./console.sh doctrine:migrations:migrate --env=test --no-interaction - - ./console.sh doctrine:fixtures:load --env=test --no-interaction +.test_definition: &test_definition + services: + - chill/database:latest + + before_script: + - composer config github-oauth.github.com $GITHUB_TOKEN + - if [ $CI_BUILD_REF_NAME = "1.0" ] ; then export COMPOSER_ROOT_VERSION="1.0-dev"; else export COMPOSER_ROOT_VERSION="dev-master"; fi + - composer install --no-interaction --ignore-platform-reqs + - cp Tests/Fixtures/App/app/config/parameters.gitlab-ci.yml Tests/Fixtures/App/app/config/parameters.yml + - ./console.sh --env=test cache:warmup + - ./console.sh doctrine:migrations:migrate --env=test --no-interaction + - ./console.sh doctrine:fixtures:load --env=test --no-interaction test:php-5.6: stage: test + image: chill/ci-image:php-5.6 + <<: *test_definition script: phpunit test:php-7: stage: test image: chill/ci-image:php-7 + <<: *test_definition script: phpunit + +deploy-packagist: + stage: deploy + image: chill/ci-image:php-7 + before_script: + # test that PACKAGIST USERNAME and PACKAGIST_TOKEN variable are set + - if [ -z ${PACKAGIST_USERNAME+x} ]; then echo "Please set PACKAGIST_USERNAME variable"; exit -1; fi + - if [ -z ${PACKAGIST_TOKEN+x} ]; then echo "Please set PACKAGIST_TOKEN variable"; exit -1; fi + script: + - STATUSCODE=$(curl -XPOST -H'content-type:application/json' "https://packagist.org/api/update-package?username=$PACKAGIST_USERNAME&apiToken=$PACKAGIST_TOKEN" -d"{\"repository\":{\"url\":\"$CI_PROJECT_URL.git\"}}" --silent --output /dev/stderr --write-out "%{http_code}") + - if [ $STATUSCODE = "202" ]; then exit 0; else exit $STATUSCODE; fi