Deploy the demos from one fly.toml, main's as pro-tacts
One config cannot hold both apps' [env] branding, so demo.ru now
reads what a run calls itself from the FLY_APP_NAME the platform
hands every machine.
Assisted-by: GLM-5.3 via pi
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 19145e2..19d97fa 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -87,22 +87,22 @@ jobs:
run: gh release create "${STEPS_META_OUTPUTS_VERSION}" --target "$GITHUB_SHA" --generate-notes
deploy:
- name: Deploy base demo
+ name: Deploy main preview
needs: build
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
runs-on: ubuntu-latest
permissions:
- contents: read # checkout, for fly.base.toml
+ contents: read # checkout, for fly.toml
environment:
name: demo
- url: https://pro-tacts-base.fly.dev
+ url: https://pro-tacts.fly.dev
# One deploy at a time, and a newer main is the one worth having.
concurrency:
group: fly-deploy
cancel-in-progress: true
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
- FLY_APP: pro-tacts-base
+ FLY_APP: pro-tacts
FLY_ORG: personal
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
@@ -119,9 +119,7 @@ jobs:
# The image the build job just pushed, rather than a second build
# of the same commit: what the demo runs is then the release.
- # --config is named because the file is not fly.toml; see its head
- # for why it is not.
- name: Deploy the released image
env:
NEEDS_BUILD_OUTPUTS_IMAGE: ${{ needs.build.outputs.image }}
- run: flyctl deploy --app "$FLY_APP" --config fly.base.toml --image "$NEEDS_BUILD_OUTPUTS_IMAGE"
+ run: flyctl deploy --app "$FLY_APP" --config fly.toml --image "$NEEDS_BUILD_OUTPUTS_IMAGE"
diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml
index 534b4da..12284e4 100644
--- a/.github/workflows/preview.yml
+++ b/.github/workflows/preview.yml
@@ -37,5 +37,5 @@ jobs:
id: deploy
uses: superfly/fly-pr-review-apps@f5d85309215d5700e7a42faf9aa5e9a718aaef7c # 1.5.0
with:
- config: fly.preview.toml
+ config: fly.toml
memory: 256
diff --git a/demo.ru b/demo.ru
index d255d08..f088f32 100644
--- a/demo.ru
+++ b/demo.ru
@@ -1,9 +1,10 @@
# The demo entrypoint: the fixture book, and a login written the way the
-# proxy would write it. Both the dev server (dev.ru, which adds what
-# marks a dev run) and the preview app (fly.preview.toml, which runs this
-# file) serve from here, so the two differ in their branding and nothing
-# else. A deployment runs config.ru, which has neither the seed nor the
-# login and reads no flag that would turn them on.
+# proxy would write it. The dev server (dev.ru, which adds what marks a
+# dev run) and the two Fly apps (fly.toml, which runs this file for both
+# the per-PR previews and the app deployed from main) serve from here,
+# so they differ in their branding and nothing else. A deployment runs
+# config.ru, which has neither the seed nor the login and reads no flag
+# that would turn them on.
require "pathname"
$LOAD_PATH.unshift(Pathname.new(__dir__) / "lib")
@@ -11,6 +12,18 @@ require "pro_tacts"
require "pro_tacts/stub_login"
require_relative "test/fixture_data"
+# What a Fly app calls itself, read from the name the platform hands the
+# machine: the review-app action names a preview pr-<number>-...
+# (.github/workflows/preview.yml), and anything else running this file
+# is main's app. Set only where unset, so an exported variable still
+# wins; FLY_APP_NAME is absent off Fly, so dev names its own run in
+# dev.ru untouched.
+if (app_name = ENV["FLY_APP_NAME"])
+ preview = app_name.match?(/\Apr-\d+-/)
+ ENV["PRO_TACTS_INSTANCE_NAME"] ||= preview ? "pro-tacts (preview)" : "pro-tacts (main)"
+ ENV["PRO_TACTS_ACCENT"] ||= preview ? "clay" : "teal"
+end
+
config = ProTacts.config
# Seeded when there is no database yet, not on every boot: a fresh data
diff --git a/fly.base.toml b/fly.base.toml
deleted file mode 100644
index 99f926f..0000000
--- a/fly.base.toml
+++ /dev/null
@@ -1,40 +0,0 @@
-# The base demo app, deployed from main by the deploy job in
-# .github/workflows/ci.yml, so a pull request's preview has something to
-# be read against: the same app one commit behind, or one design
-# decision behind. It runs demo.ru rather than the image's own
-# config.ru, exactly as the per-PR previews do -- the fixture book
-# seeded on first boot, and a stand-in login, since nothing writes the
-# identity header in front of it either. No volume, so every deploy
-# starts from the fixtures again.
-#
-# Named fly.base.toml rather than fly.toml, and passed to every command
-# with --config: `flyctl launch --copy-config` inside the review-app
-# action reads whatever fly.toml it finds, so a file by that name would
-# put this app's settings in the middle of building a preview's.
-#
-# The app name is Fly's, not GitHub's, so it has to be unique across all
-# of Fly and a taken one fails the deploy. ci.yml spells it twice more,
-# as FLY_APP to create it on the first deploy and in the environment's
-# URL, so a rename here is a rename in three places.
-app = 'pro-tacts-base'
-primary_region = 'sjc'
-
-[processes]
- app = 'rackup -o 0.0.0.0 demo.ru'
-
-[http_service]
- internal_port = 9292
- force_https = true
- auto_stop_machines = 'stop'
- auto_start_machines = true
- min_machines_running = 0
- processes = ['app']
-
-[[vm]]
- memory = '256mb'
- cpu_kind = 'shared'
- cpus = 1
-
-[env]
- PRO_TACTS_INSTANCE_NAME = 'pro-tacts (main)'
- PRO_TACTS_ACCENT = 'teal'
diff --git a/fly.preview.toml b/fly.preview.toml
deleted file mode 100644
index 245d35f..0000000
--- a/fly.preview.toml
+++ /dev/null
@@ -1,30 +0,0 @@
-# The per-PR preview app (fly-pr-review-apps overrides the name with the
-# PR's). It runs demo.ru rather than the image's own config.ru, which is
-# the whole of what makes it a demo: the fixture book seeded on first
-# boot, and a stand-in login, the same two the dev server gets. No
-# volume, so every deploy starts from the fixtures again, and the one
-# demo book is served to anyone who opens the URL.
-app = 'pro-tacts-preview'
-primary_region = 'sjc'
-
-[build]
-
-[processes]
- app = 'rackup -o 0.0.0.0 demo.ru'
-
-[http_service]
- internal_port = 9292
- force_https = true
- auto_stop_machines = 'stop'
- auto_start_machines = true
- min_machines_running = 0
- processes = ['app']
-
-[[vm]]
- memory = '256mb'
- cpu_kind = 'shared'
- cpus = 1
-
-[env]
- PRO_TACTS_INSTANCE_NAME = 'pro-tacts (preview)'
- PRO_TACTS_ACCENT = 'clay'
diff --git a/fly.toml b/fly.toml
new file mode 100644
index 0000000..7c22244
--- /dev/null
+++ b/fly.toml
@@ -0,0 +1,36 @@
+# The one Fly config, for the two demo apps: the app main deploys (the
+# deploy job in .github/workflows/ci.yml) and the per-PR previews (the
+# review-app action in .github/workflows/preview.yml, which overrides
+# the app name with the PR's). Both run demo.ru rather than the image's
+# own config.ru, which is the whole of what makes them demos: the
+# fixture book seeded on first boot, and a stand-in login, since nothing
+# writes the identity header in front of either. No volume, so every
+# deploy starts from the fixtures again, and the one demo book is
+# served to anyone who opens the URL. What each app calls itself is not
+# here -- demo.ru reads it from the app name the platform hands the
+# machine.
+#
+# The app name is Fly's, not GitHub's, so it has to be unique across all
+# of Fly and a taken one fails the deploy. ci.yml spells it twice more,
+# as FLY_APP to create it on the first deploy and in the environment's
+# URL, so a rename here is a rename in three places.
+app = 'pro-tacts'
+primary_region = 'sjc'
+
+[build]
+
+[processes]
+ app = 'rackup -o 0.0.0.0 demo.ru'
+
+[http_service]
+ internal_port = 9292
+ force_https = true
+ auto_stop_machines = 'stop'
+ auto_start_machines = true
+ min_machines_running = 0
+ processes = ['app']
+
+[[vm]]
+ memory = '256mb'
+ cpu_kind = 'shared'
+ cpus = 1