I am very new to fly (literally started with it today, my lord it’s good).
I’m trying to set up a nice CD flow from GitHub. The official docs for this suggest this GitHub Actions workflow:
name: Fly Deploy
on: [push]
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
jobs:
deploy:
name: Deploy app
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: superfly/flyctl-actions/setup-flyctl@master
- run: flyctl deploy --remote-only
But I need DATABASE_URL
to be available during build/deployment, as my Node app (Next.js) generates static pages based on info from the database.
It looks like one solution would be to add DATABASE_URL
(the .internal
one that Fly generated for me when I created my app and said “yes” to setting up a database) to my GitHub repo’s secrets, and then add --build-arg DATABASE_URL="${{ secrets.DATABASE_URL }}"
to the flyctl
command in the workflow above.
But it feels a tad clunky and I’m wondering if there’s a simpler approach I’m missing?
Another option that occurred to me is: just set the secret directly on the ‘builder app’ that Fly auto-created for building my app, i.e.
> flyctl secrets set -a fly-builder-tasty-moonlight-5678 DATABASE_URL="postgres://........."
This (if it works) feels a bit nicer and more secure than sharing the secret with GitHub so GitHub can provide the secret to fly.io.
But I’m not sure if the builder app is supposed to be considered ‘persistent’, i.e. is it sensible to assign it a secret? It was created for me automatically, I’m not sure if it might get randomly replaced with another builder app later. On the other hand, it does appear to be basically just an app, and it has a ‘secrets’ tab on the dashboard, so why not?
Alternatively, is there any more ‘official’ way to share secrets between an app and its builder?