Dealing with flyctl interactive prompt in a CI environment


flyctl commands have a variable way of dealing with the app name and sometimes fallback to an interactive prompt which is really not practical on a CI environment like GitHub Actions.

Here’s what I’m trying to do:
I want to create review environments on each PR on my GitHub repository and for that, I want to create a new app with a PG cluster attached to it.
My repo already has a fly.toml file for the production environment and I’d love to be able to use it without hassle for everything.

In my script, I use $app for the web application and $postgres_app for the PG application.

The first problem is that I can’t have the app name in the fly.toml because just doing a flyctl launch --name "$app" without --copy-config would result in a blocking interactive prompt asking me if I really want to use the name $app which, in a CI environment automatically fails.

This can be fixed by using a --copy-config flag but it will create a new fly.toml file that will have the $app name inside.

Most of the commands for creating a PG cluster work fine with the --app flag without asking anything but when it’s time to create the cluster with flyctl scale count 3 --app "$postgres_app", flyctl stop and asks if I want to continue because the name in the fly.toml is not the same which, once again, fails in CI.

There doesn’t seem to be any consistent way to avoid interactive prompts and I had to end up copying the fly.toml file to fly-postgres.toml and doing a sed command to update the app name:

cp fly.toml fly-postgres.toml
sed -i "s/app = \"$app\"/app = \"$postgres_app\"/" fly-postgres.toml

In order to be able to make the scale command with --config fly-postgres.toml.

So, it works but it would really be better to have a --force-app-name or something that prevents the CLI asking if we’re sure we want to ignore the app name in the fly.toml.

Is it something that is in the roadmap somewhere? Is there maybe a method that I didn’t see in the documentation?


Might want to leave this comment on the bug report here: Some flyctl commands do not provide a flag to confirm prompts in advance · Issue #933 · superfly/flyctl · GitHub

1 Like