Tips and tricks

๐Ÿš€ Deploy to Fly.io Using GitHub Actions (With API Token)

This guide shows how to securely deploy your project to Fly.io using a GitHub Actions workflow and an API token.


1๏ธโƒฃ Generate Your Fly Deploy Token

Run this command locally:

fly tokens create deploy -x 999999h

This will generate a long-lived deploy token.

โš ๏ธ Copy the token immediately โ€” you will not be able to see it again.


2๏ธโƒฃ Add the Token to GitHub Secrets

Go to your GitHub repository:

Repository โ†’ Settings โ†’ Secrets and variables โ†’ Actions

Then:

  1. Click New repository secret
  2. Name it:
FLY_API_TOKEN
  1. Paste the token generated in Step 1
  2. Click Add secret

Your token is now securely stored and encrypted inside GitHub.


3๏ธโƒฃ Update Your GitHub Workflow

Inside your repository, edit or create:

.github/workflows/deploy.yml

Make sure your workflow includes:

- name: Deploy to Fly
run: flyctl deploy --remote-only
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}

๐Ÿ” What This Does

  • Uses your stored GitHub secret
  • Injects it into the environment at runtime
  • Authenticates flyctl securely
  • Deploys your app to Fly.io

No tokens stored in code. No hardcoded credentials.


โœ… Final Flow

GitHub Push
โ†“
GitHub Actions
โ†“
FLY_API_TOKEN (Secret)
โ†“
flyctl deploy --remote-only
โ†“
Fly.io Deployment

If

Leave a comment

Your email address will not be published

{"type":"main_options","images_arr":"'#ffffff'","bg_slideshow_time":"0","site_url":"https:\/\/digitalzoomstudio.net","theme_url":"https:\/\/digitalzoomstudio.net\/wp-content\/themes\/qucreative\/","is_customize_preview":"off","gallery_w_thumbs_autoplay_videos":"off","base_url":"https:\/\/digitalzoomstudio.net"}