Add GHA for deploying preview branches to Fly.io
Uses superfly/fly-pr-review-apps to automatically deploy PR preview
environments. A separate fly.preview.toml omits the [build] image
section so the Dockerfile is used to build the PR's code rather than
pulling the production image.
https://claude.ai/code/session_01VBL9BP4oFmJkBQbyMzJz8j
diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml
new file mode 100644
index 0000000..93981e5
--- /dev/null
+++ b/.github/workflows/preview.yml
@@ -0,0 +1,27 @@
+name: Preview
+
+on:
+ pull_request:
+ types: [opened, reopened, synchronize, closed]
+
+env:
+ FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
+ FLY_REGION: sjc
+ FLY_ORG: personal
+
+jobs:
+ preview:
+ runs-on: ubuntu-latest
+ concurrency:
+ group: pr-${{ github.event.number }}
+ environment:
+ name: pr-${{ github.event.number }}
+ url: ${{ steps.deploy.outputs.url }}
+ steps:
+ - uses: actions/checkout@v6
+ - name: Deploy preview
+ id: deploy
+ uses: superfly/fly-pr-review-apps@1.5.0
+ with:
+ config: fly.preview.toml
+ memory: 256
diff --git a/fly.preview.toml b/fly.preview.toml
new file mode 100644
index 0000000..5dd70a4
--- /dev/null
+++ b/fly.preview.toml
@@ -0,0 +1,21 @@
+app = 'ketchup-preview'
+primary_region = 'sjc'
+
+[http_service]
+ internal_port = 9292
+ force_https = true
+ auto_stop_machines = 'stop'
+ auto_start_machines = true
+ min_machines_running = 0
+ processes = ['app']
+
+[[vm]]
+ memory = '1gb'
+ cpu_kind = 'shared'
+ cpus = 1
+ memory_mb = 256
+
+[env]
+ DATABASE_URL = ':memory:'
+ SENTRY_ENV = 'preview'
+ DEFAULT_USER = 'demo@example.com:Demo User'