Skip to content

Deploy to Fly via GitHub action

New Courses Coming Soon

Join the waiting lists is a very cool cloud hosting platform but one thing I miss is automatic deploy when I do a GitHub commit, as the services are not linked to GitHub.

To add CD (Continuous Deployment) to we need to create a GitHub action.

I suppose you already have a Fly app running and a fly.toml file in your repo like I describe in

In your project repo, create .github/workflows/fly.yml

name: Fly Deploy
      - mod12
    name: Deploy app
    runs-on: ubuntu-latest
    concurrency: deploy-group
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
          node-version: 20
      - uses: superfly/flyctl-actions/setup-flyctl@master
      - run: flyctl deploy --remote-only
          FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}

I took this from but updated the checkout version to v4 and added the setup-node step to setup Node 20, as the repo is an Astro site and I want it to use LTS Node.

Make sure you set the name of the branch you want to deploy (in this example, I deploy a branch named mod12).

In your terminal run

fly tokens create deploy -x 999999h

to generate the Fly token and add it to the actions secrets in GitHub:

Call the secret FLY_API_TOKEN and enter the value you got from fly tokens...

Push to GitHub, you’ll see your action running:

You can see all the details of the action by clicking it:

In the jobs tab you can see what happened in the build:

Go on Fly, you’ll see the action was successful:

and the app is deployed on every commit.

All your deploys also have a “check” now to indicate that the action was successful (or not)

Here is how can I help you: