The Ultimate Guide to Deploying on Fly.io with GitHub Actions
Tags: flyio, githubactions, shecodeafrica
Published: 2023-06-12 13:49:54

---
title: The Ultimate Guide to Deploying on Fly.io with GitHub Actions
published: true
date: 2023-06-08 14:24:21 UTC
tags: flyio, githubactions, shecodeafrica
canonical_url: https://emaomokiti.hashnode.dev/the-ultimate-guide-to-deploying-on-flyio-with-github-actions
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zoc1jxb0bmetncr7d9r2.png
---

I came across [Fly.io](https://fly.io/). when I was looking for another platform to deploy my applications other than the ones I already knew.

Fly.io is a platform that help's you deploy your application just like Netlify, Vercel, etc. It doesn't matter what framework you are using, Fly.io got you covered 😉.

## Steps to Deploy on Fly.io with GitHub

### Step 1

Sign up on Fly.io

Go to [Fly.io](https://fly.io/) and click on the **Sign Up** button

![The Fly Sign Up button](https://cdn.hashnode.com/res/hashnode/image/upload/v1686054585016/43c6ca0a-3ac9-40f5-9e6c-6b942301270f.png)

### Step 2

Sign up using your GitHub account or Email

![Fly Sign up Page](https://cdn.hashnode.com/res/hashnode/image/upload/v1686055350023/d67d533d-1a4b-4236-b0e4-92bad0669440.png)

I will sign up and sign in using my GitHub account.

### Step 3

You will be routed to your dashboard. Click on **Billing** to add a credit card. All plans on Fly.io need a credit card.

According to Fly.io

> We don't offer a "free tier." Instead, we offer some free resource allowances that apply to all plans, including the Hobby plan, and includes enough usage per month to run a small full-stack app, full-time, for free.

![Fly dashboard billing tab](https://cdn.hashnode.com/res/hashnode/image/upload/v1686138383990/ac3749e7-8349-4654-b9ad-a0667a9496c6.png)

### Step 4

Install flyctl

flyctl is a command line utility that helps you work with Fly.io in your terminal.

Install based on your operating system. I will install flyctl using brew

MacOS

```zsh
brew install flyctl

```

Linux

```zsh
curl -L https://fly.io/install.sh | sh

```

Windows

```zsh
pwsh -Command "iwr https://fly.io/install.ps1 -useb | iex"

```

### Step 5

Since you have installed flyctl on your terminal, you will have access to fly.io commands. Run the following command in the root directory of your app

```zsh
fly launch

```

![Image of Terminal](https://cdn.hashnode.com/res/hashnode/image/upload/v1686136427752/5e077140-85b2-4099-b213-b4f9311955e2.png)

When you run the command above, you will be asked a series of questions such as;

- Choose an app name (leave blank to generate one): You can give your app a name or leave it blank so Fly.io will generate one for you.

- Choose a region for deployment: some regions are not free. You can check out more about regions on the Fly.io Docs

- Would you like to deploy now? : You will select No because we want to sync our app with GitHub

### Step 6

Get a Fly.io token by running the command below. Copy the output and paste it somewhere because you will need it later.

```zsh
 fly tokens create deploy -x 999999h

```

### Step 7

Go to the GitHub Repository of the app you want to deploy and Click on **Settings**

![Settings tab of author repository](https://cdn.hashnode.com/res/hashnode/image/upload/v1686059272060/cf87194f-207e-4773-ad27-6e725969ede5.png)

### Step 8

You will be routed to the settings page, scroll down to the **Security section** and click on **Secrets and variables** and select **Actions**

![Security section of the author repository](https://cdn.hashnode.com/res/hashnode/image/upload/v1686059831215/4a2948b6-ce12-435a-8931-fac8d295ab8b.png)

### Step 9

You will be routed to the secrets page click on the **New repository secret** button

![secrets page](https://cdn.hashnode.com/res/hashnode/image/upload/v1686059978586/f0b8c6b0-5a3b-4eb7-8e42-f889136a6013.png)

### Step 10

Give your action secret a name. I will name mine **FLY\_API\_TOKEN.** In the secret field, paste the token you got in **Step 5** and click **on the Add secret button.**

![Action Secret Page](https://cdn.hashnode.com/res/hashnode/image/upload/v1686060030304/18cfc0d2-097e-4c1d-8fc3-42cad76c30a6.png)

### Step 11

Go back to your IDE(Integrated Development Environment) and do the following ;

1. In the root of your app directory create a folder and name it. **github** If you don't have one like me.

2. Inside the **.github** folder create another folder and name it **workflows**

3. In the workflows folder create a file and name it **fly.yml**

4. Paste the code below inside the **fly.yml**

```
name: Fly Deploy
on:
  push:
    branches:
      - main
jobs:
  deploy:
    name: Deploy app
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: superfly/flyctl-actions/setup-flyctl@master
      - run: flyctl deploy --remote-only
        env:
          FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}

```

### Step 12

Commit your changes and push them to GitHub. Click on the **Actions** tab of your repository to see the deployment in progress.

![Actions page](https://cdn.hashnode.com/res/hashnode/image/upload/v1686069986198/307e6f05-ebb3-4406-9148-ea6c5d724600.png)

### Step 13

If you go to your Fly.io dashboard you will see your deployed app

![Fly Dashboard](https://cdn.hashnode.com/res/hashnode/image/upload/v1686071250695/9c128095-9c06-4a92-93cd-847f2d1396c6.png)

Click on your app name to see details of your app

### Step 14

Click on the **Hostname** you would be able to access your app.

![Author app details](https://cdn.hashnode.com/res/hashnode/image/upload/v1686071303847/d9690cc6-ac2d-4363-bce2-454aa9b0b229.png)

### Conclusion

From **Step 5** you can deploy your app when asked **Would you like to deploy now?** If you had selected yes, your app would have been deployed but when you make changes to your application, you will have to repeat **the fly launch process**.

You went through this route so that when you make changes to your app and push it to GitHub, It would automatically be deployed and you don't have to repeat **the fly launch**  **process** when you make changes to your app.

Let me know what you think about Fly.io.

Happy Coding!!!