Skip to main content
Laravel applications are alive and bustling with feature updates and revisions. You’ll want to add your Laravel Fly App in a GitHub repository for safe-versions-keeping, healthy-code-reviews, and good-old team-code management. Once you’ve set up a repository for your Fly App, you can automate your team’s deployment workflow with GitHub Actions---a really neat way to automate most things you’d manually do during and after code reviews!

Initialization

In this section, you’ll create a new Laravel application, configure and deploy it as a Fly App, and finally add it to a GitHub repository.
  1. Start with a clean slate: create a new Laravel project and configure it as a deployable Fly app by using the flyctl launch command:
  2. Create a new github repository for your current Laravel Fly App. You can create one either through:
    1. GitHub Console - Visiting your create a new repository page in your console
    2. GitHub CLI - run the create repo command:
  3. Finally, initialize your Laravel Fly App’s directory as part of a git repository, and point its remote to the recently created repository above

GitHub CI Action: Auto Deploy to Fly.io

Once you have your Laravel application set up with a github repository, you can configure some GitHub Actions to auto deploy your changes. In this guide, you’ll be using Fly.io’s very own GitHub action template here to help deploy your application.
  1. Generate a Fly token with fly tokens deploy
  2. Then save your newly generated FLY_API_TOKEN in your github repository either through the GitHub Console or GitHub CLI:
    1. GitHub Console - Open your repository’s Settings tab, then add a secret named FLY_API_TOKEN under the Secrets section.
    2. GitHub CLI - run the command below
  3. Once you have your FLY_API_TOKEN safely stored as a secret in your github repository, proceed with creating a GitHub workflow yml file in .github/workflows/main.yml:
    Let’s go through each line above, shall we?
    • name: Fly Deploy => This is the Workflow name
    • on: [push] => Any push action to the repository triggers the current workflow
    • env: `FLY_API_TOKEN` => Environment variable set for the GitHub Actions container
    • jobs: => This is the list of jobs to run for the workflow
      • name: Deploy app => Each job would have a name
      • runs-on: ubuntu-latest => Each job would have an container environment we want to run its virtual machine on
      • steps: => Each job would have a list of steps, see below:
        • uses: actions/checkout@v2 => This is a pre-made GitHub Action. It allows checking out of your repository into the virtual machine spun up for the job
        • uses: superfly/flyctl-actions/setup-flyctl@master => This is one of Fly.io’s pre-made GitHub action. It sets up `flyctl` in the virtual machine spun up for the job
        • run: flyctl deploy => Need I say more?
  4. Save and push your changes with:
  5. Visit the Actions tab of your repository and see how your deployment fares!