Changed travis build so that docker image publishing runs on its own separated job

This commit is contained in:
Alejandro Celaya 2020-05-16 13:28:29 +02:00
parent 9252cc269b
commit 09aa4cc977
2 changed files with 27 additions and 21 deletions

View File

@ -6,8 +6,17 @@ branches:
only:
- /.*/
php:
- '7.4'
jobs:
include:
- name: "Docker publish"
php: '7.4'
if: env(TRAVIS_PULL_REQUEST) = 'false'
env:
- DOCKER_PUBLISH="true"
- name: "CI"
php: '7.4'
env:
- DOCKER_PUBLISH="false"
services:
- docker
@ -17,32 +26,33 @@ cache:
- $HOME/.composer/cache/files
before_install:
- sudo ./data/infra/ci/install-docker.sh
- sudo ./data/infra/ci/install-ms-odbc.sh
- docker-compose -f docker-compose.yml -f docker-compose.ci.yml up -d shlink_db_ms shlink_db shlink_db_postgres shlink_db_maria
- yes | pecl install pdo_sqlsrv swoole-4.4.18
- echo 'extension = apcu.so' >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
- phpenv config-rm xdebug.ini || return 0
- if [[ "${DOCKER_PUBLISH}" == 'false' ]]; then sudo ./data/infra/ci/install-docker.sh ; fi
- if [[ "${DOCKER_PUBLISH}" == 'false' ]]; then sudo ./data/infra/ci/install-ms-odbc.sh ; fi
- if [[ "${DOCKER_PUBLISH}" == 'false' ]]; then docker-compose -f docker-compose.yml -f docker-compose.ci.yml up -d shlink_db_ms shlink_db shlink_db_postgres shlink_db_maria ; fi
- if [[ "${DOCKER_PUBLISH}" == 'false' ]]; then yes | pecl install pdo_sqlsrv swoole-4.4.18 ; fi
install:
- composer self-update
- composer install --no-interaction --prefer-dist
- if [[ "${DOCKER_PUBLISH}" == 'false' ]]; then composer self-update ; fi
- if [[ "${DOCKER_PUBLISH}" == 'false' ]]; then composer install --no-interaction --prefer-dist ; fi
before_script:
- docker-compose exec shlink_db_ms /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 'Passw0rd!' -Q "CREATE DATABASE shlink_test;"
- if [[ "${DOCKER_PUBLISH}" == 'false' ]]; then docker-compose exec shlink_db_ms /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 'Passw0rd!' -Q "CREATE DATABASE shlink_test;" ; fi
- mkdir build
- export DOCKERFILE_CHANGED=$(git diff ${TRAVIS_COMMIT_RANGE:-origin/master} --name-only | grep Dockerfile)
script:
- composer ci
- if [[ ! -z "${DOCKERFILE_CHANGED}" && "${TRAVIS_PHP_VERSION}" == "7.4" && "${TRAVIS_PULL_REQUEST}" != 'false' ]]; then docker build -t shlink-docker-image:temp . ; fi
- if [[ "${DOCKER_PUBLISH}" == 'false' ]]; then composer ci ; fi
- if [[ ! -z "${DOCKERFILE_CHANGED}" && "${TRAVIS_PHP_VERSION}" == "7.4" && "${DOCKER_PUBLISH}" == "false" ]]; then docker build -t shlink-docker-image:temp . ; fi
- if [[ "${DOCKER_PUBLISH}" == 'true' ]]; then bash ./docker/build ; fi
after_success:
- rm -f build/clover.xml
- wget https://phar.phpunit.de/phpcov-7.0.2.phar
- phpdbg -qrr phpcov-7.0.2.phar merge build --clover build/clover.xml
- wget https://scrutinizer-ci.com/ocular.phar
- php ocular.phar code-coverage:upload --format=php-clover build/clover.xml
- if [[ "${DOCKER_PUBLISH}" == 'false' ]]; then wget https://phar.phpunit.de/phpcov-7.0.2.phar ; fi
- if [[ "${DOCKER_PUBLISH}" == 'false' ]]; then phpdbg -qrr phpcov-7.0.2.phar merge build --clover build/clover.xml ; fi
- if [[ "${DOCKER_PUBLISH}" == 'false' ]]; then wget https://scrutinizer-ci.com/ocular.phar ; fi
- if [[ "${DOCKER_PUBLISH}" == 'false' ]]; then php ocular.phar code-coverage:upload --format=php-clover build/clover.xml ; fi
# Before deploying, build dist file for current travis tag
before_deploy:
@ -56,11 +66,6 @@ deploy:
file: "./build/shlink_${TRAVIS_TAG#?}_dist.zip"
skip_cleanup: true
on:
condition: "${DOCKER_PUBLISH}" == 'false'
tags: true
php: '7.4'
- provider: script
script: bash ./docker/build
on:
all_branches: true
condition: "${TRAVIS_PULL_REQUEST}" == 'false'
php: '7.4'

View File

@ -1,4 +1,5 @@
#!/bin/bash
set -e
BUILDX_VER=v0.4.1