fix deploy command and improve scripts

The scripts now test that variables are set.
The "deploy to packagist" build should return an error if not successful.
This commit is contained in:
Julien Fastré 2016-11-19 19:15:18 +01:00
parent 5ac623075d
commit 6ec1d44978

View File

@ -2,7 +2,7 @@
services: services:
- chill/database:latest - chill/database:latest
before_script: before_script:
- composer config github-oauth.github.com $GITHUB_TOKEN - if [ -z ${GITHUB_TOKEN+x} ]; then composer config github-oauth.github.com $GITHUB_TOKEN; fi
- composer install --no-interaction - composer install --no-interaction
- cp Tests/Fixtures/App/app/config/parameters.gitlab-ci.yml Tests/Fixtures/App/app/config/parameters.yml - cp Tests/Fixtures/App/app/config/parameters.gitlab-ci.yml Tests/Fixtures/App/app/config/parameters.yml
- php Tests/Fixtures/App/app/console.php --env=test cache:warmup - php Tests/Fixtures/App/app/console.php --env=test cache:warmup
@ -23,6 +23,10 @@ test:php-7:
deploy-packagist: deploy-packagist:
stage: deploy stage: deploy
image: chill/ci-image:php-7 image: chill/ci-image:php-7
before_script: ~ 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: script:
- curl -XPOST -H'content-type:application/json' "https://packagist.org/api/update-package?username=$PACKAGIST_USERNAME&apiToken=$PACKAGIST_TOKEN" -d"{\"repository\":{\"url\":\"$CI_PROJECT_PATH.git\"}}" - 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\"}}")
- if [ $STATUSCODE = "202" ]; then exit 0; else exit $STATUSCODE; fi