Home Posts Post Search Tag Search

Game Site Journal - 04
Published on: 2025-04-12 Tags: Blog, Side Project, LiveView, Game Site, Fly, Deployment

This is a quick post to show you how to deploy with Fly.io

Follow the Phoenix Deploying on Fly.io guide to deploy the project. https://hexdocs.pm/phoenix/fly.html

Install Fly.io Command line https://fly.io/docs/flyctl/install/

fly auth signup

to signup for your account and make your shell know who you are

fly launch

to start the first deployment you should see something like:

? Choose an app name (leave blank to generate one): replace-this-with-your-app-name
? Choose a region for deployment: pick-the-default-or-select-your-region
? Would you like to set up a Postgresql database now? Yes
? Select configuration: Development - Single node, 1x shared CPU, 256MB RAM, 1GB disk
? Scale single node pg to zero after one hour? Yes
? Would you like to set up an Upstash Redis database now? No
? Would you like to deploy now? Yes

Once this is done the current version of your code is deployed. If you want to use a specific branch only and update it whenever that branch gets a pull request follow the next steps.

fly auth token

to get a token for deployment, be sure to head to the settings section of the GitHub page for your repository. Then head to Secrets and variables → Actions and add a Repository Secret with the name FLY_API_TOKEN.

Then you can create .github/workflows/continuous-deployment.yml file with the following content. Notice this uses the secret token you just configured:

name: Fly Deploy
on:
  push:
    branches:
      - main
env:
  FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
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

Where main is the name of the branch you want to update off of.

Keep in mind at the time of writing this you can only have 2 sites active for free and you will need some money in your account to move out of the trial phase and keep your sites up.