Home Arrow Icon Knowledge base Arrow Icon Global Arrow Icon Can I use Laravel Forge for automated deployments triggered by Travis CI
    Laravel Forge


Can I use Laravel Forge for automated deployments triggered by Travis CI


Yes, you can use Laravel Forge for automated deployments triggered by Travis CI. Here's how to set it up:

1. In Forge, create a deployment trigger URL that Travis CI can use to initiate deployments on your server. This trigger URL is found in the "Deployment Trigger" section of your site's settings in Forge.

2. In Travis CI, add the `FORGE_API_TOKEN` environment variable to your build environment. You can generate an API token in the API settings of your Forge account. This allows Travis to authenticate with Forge during deployments.

3. Configure Travis to run your tests and build your Laravel application as usual. If the tests pass, add a deployment step that uses the `forge deploy` command to trigger a deployment on your Forge server using the deployment trigger URL.

4. Optionally, you can also add the `SSH_PRIVATE_KEY` environment variable in Travis so that it can SSH into your Forge server during deployment. This allows you to execute additional commands like restarting services.

5. Whenever you push code to the configured branch in your Git repository, Travis will run the tests. If successful, it will trigger a deployment on Forge using the deployment trigger URL. Forge will then handle provisioning the server, installing dependencies, and deploying your application.

By integrating Travis CI and Laravel Forge, you get the benefits of both tools - Travis handles the continuous integration and testing, while Forge manages the server provisioning and deployment. This allows you to set up a robust, automated CI/CD pipeline for your Laravel projects.

The key is configuring the necessary authentication between the two tools, which involves setting environment variables in Travis and using the deployment trigger URL provided by Forge. With this integration in place, pushing code will automatically trigger a build, test, and deploy process using Travis and Forge[1][2][3].

Citations:
[1] https://forge.laravel.com/docs/sites/deployments.html
[2] https://laracasts.com/discuss/channels/forge/deploying-to-forge-from-travis-ci
[3] https://www.danielwerner.dev/set-up-cicd-for-your-laravel-app-with-github-travis-and-deployer
[4] https://stackshare.io/stackups/laravel-forge-vs-travis-ci
[5] https://www.reddit.com/r/laravel/comments/js227r/laravel_forge_and_cicd/