tofran
June 20, 2022, 8:45am
21
There’s great content here. I will leave here also how we do it (similar to @aswinmohanme ):
build-and-deploy:
name: Build and deploy
runs-on: ubuntu-latest
needs:
# (...)
steps:
- uses: actions/checkout@v2
- uses: superfly/flyctl-actions/setup-flyctl@master
- run: flyctl -a our-app-staging deploy --remote-only
if: github.ref == 'refs/heads/develop'
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
- run: flyctl -a our-app-production deploy --remote-only
if: github.ref == 'refs/heads/main'
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
Locally there’s a handy env var FLY_APP
(ex: export FLY_APP=our-app-name
) , you could also pass -a our-app-name
on every fly command or
1 Like
tbrlpld
September 19, 2022, 3:29pm
22
I like the idea of having the two scripts. But I was also thinking having something akin to the Heroku piplines could be nice.
A caveat: This -a <staging-or-prod>
trick doesn’t work with Machine apps (yet): Preview: Deploying applications on Machines with flyctl - #6 by ignoramous
Well, “pipelines” seems to be on Fly’s roadmap anti-roadmap: Rough edges for multi-app services - #2 by kurt
I keep the app name in the fly toml the staging app, and when I want to deploy production I promote the latest staging image to production, so I never build a new image for production, simply deploy one of staging’s images:
#!/usr/bin/env ruby
require "json"
js = JSON.parse(`flyctl image show --json`)
registry = js["Registry"]
tag = js["Tag"]
repo = js["Repository"]
production_app = "app-production"
cmd = "flyctl deploy -i #{registry}/#{repo}@#{tag} -a #{production_app}"
puts "----> Running #{cmd}"
system(cmd)
1 Like
password:
so I never build a new image for production, simply deploy one of staging’s images:
cmd = "flyctl deploy -i #{registry}/#{repo}@#{tag} -a #{production_app}"
Ah, similar to: Deploy fly apps using custom made bot - #3 by kurt
This works because I guess you must have already deployed the required config
(aka fly.toml
) to prod
at least once ?
drio
January 24, 2023, 10:09pm
26
Sharing my solution here.
I have two apps deployed: foo.fly.dev and foo-dev.fly.dev .
Make sure you create them running: flyctl deploy -a <appn_ame>
.
The toml file does not have an app name and my gh workflow is this:
➜ cat .github/workflows/fly.yml
name: Fly Deploy Prod
on:
push:
branches:
- main
- dev
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
- name: run_flyctl
run: |
echo "github.ref is: ${{github.ref}}"
if [[ "${{github.ref}}" == "refs/heads/main" ]]; then
echo "deploying to PROD"
flyctl deploy --remote-only -a drio-fly
fi
if [[ "${{github.ref}}" == "refs/heads/dev" ]]; then
echo "deploying to DEV"
flyctl deploy --remote-only -a drio-fly-dev
fi
1 Like