Github Action to deploy with Wasp to Fly.io
- You should first launch your app locally with
wasp deploy fly launch <basename> <region>
. - After your app is launched, make sure to commit the
fly-server.toml
andfly-client.toml
files.
-
Login with Fly.io and go here: https://fly.io/user/personal_access_tokens
-
Click
Create token
and copy that value. -
Add your Fly.io token as a repository secret e.g. calling it
FLY_TOKEN
Read more about how to do it: https://docs.github.com/en/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository
If you have configured a custom domain for your server, you can specify it as a repository secret named SERVER_URL
. If this is not defined, Wasp will default to using the <app-name>-server.fly.dev
address.
For detailed instructions on setting up repository secrets, visit: GitHub Docs: Creating Encrypted Secrets for a Repository.
You can specify the version of Wasp to use for deployment by setting the wasp-version
input. If this is not defined, Wasp will default to using the latest version.
Create a file called deploy.yml
in .github/workflows
folder in your repo with this content:
name: Deploy to Fly
on:
push:
branches:
- "main"
jobs:
deploy:
name: Deploy with Wasp
runs-on: ubuntu-latest
steps:
- uses: wasp-lang/deploy-action@main
with:
# Required: Fly.io API token
fly-token: ${{ secrets.FLY_TOKEN }}
# Optional: Override the default Fly server URL with a custom domain
server-url: ${{ secrets.SERVER_URL }}
# Optional: Set the Wasp version to use, defaults to latest
wasp-version: "0.16.0"
Notice that we are using the secrets.FLY_TOKEN
so Wasp knows how to deploy.