While developing tests for my app, I wanted to have an integration with Laravel Forge in this order:
- Push to Github after commit
- Tests done by Travis CI
- Call the deployment trigger url of Laravel Forge / Envoyer if the test runs successfully. This URL looks like: https://forge.laravel.com/servers/111111/sites/2222222/deploy/http?token=TOKEN
To do this, create a travis.yml file like:
language: php php: - 7.1 before_script: - cp .env.travis .env - mysql -e 'create database db_testing'; - composer self-update - composer install --no-interaction - php artisan migrate script: - vendor/bin/phpunit after_success: - chmod +x ./tests.sh; ./tests.sh
Don’t forget to change the environment in phpunit.xml for example to change to a custom database:
The after_success script
Create a file tests.sh and insert:
#!/bin/bash # Trigger deployment # Replace the url below with your Forge/Laravel url curl -s 'https://forge.laravel.com/servers/111111/sites/2222222/deploy/http?token=TOKEN'; echo 'Deployment triggered!'
Using other services than Travis or creating a custom test service
https://driesvints.com/blog/continuous-delivery-with-forge-and-envoyer/
Also thanks to:
Hello wolrd