-
Notifications
You must be signed in to change notification settings - Fork 646
Set up temporary Fly deployments for PRs #546
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 6 commits
4f8588a
713dddd
9e91f74
2957983
418b29a
74b01ce
a11eadb
0ff6cde
734f4b8
0fca57d
98fcb75
c9757b0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,165 @@ | ||||||||||||||
| name: 🔍 PR Preview Deploy | ||||||||||||||
|
|
||||||||||||||
| on: | ||||||||||||||
| pull_request: | ||||||||||||||
| types: [opened, synchronize, reopened, closed] | ||||||||||||||
|
|
||||||||||||||
| env: | ||||||||||||||
| FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} | ||||||||||||||
|
|
||||||||||||||
| jobs: | ||||||||||||||
| deploy-pr: | ||||||||||||||
| name: 🚀 Deploy PR Preview | ||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||
| if: github.event.action != 'closed' | ||||||||||||||
|
|
||||||||||||||
| steps: | ||||||||||||||
| - name: ⬇️ Checkout repo | ||||||||||||||
| uses: actions/checkout@v4 | ||||||||||||||
|
|
||||||||||||||
| - name: 🎈 Setup Fly | ||||||||||||||
| uses: superfly/flyctl-actions/[email protected] | ||||||||||||||
|
|
||||||||||||||
| - name: 🏷️ Generate app name | ||||||||||||||
| id: app-name | ||||||||||||||
| run: | | ||||||||||||||
| # Create a unique app name for this PR | ||||||||||||||
| APP_NAME="kcd-pr-${{ github.event.number }}" | ||||||||||||||
| echo "app_name=$APP_NAME" >> $GITHUB_OUTPUT | ||||||||||||||
| echo "url=https://$APP_NAME.fly.dev" >> $GITHUB_OUTPUT | ||||||||||||||
|
|
||||||||||||||
| - name: 📝 Setup PR-specific configurations | ||||||||||||||
| run: | | ||||||||||||||
| # Copy and modify fly.toml for PR preview | ||||||||||||||
| cp fly.toml fly.toml.backup | ||||||||||||||
|
|
||||||||||||||
| # Update app name for PR | ||||||||||||||
| sed -i 's/^app = .*/app = "${{ steps.app-name.outputs.app_name }}"/' fly.toml | ||||||||||||||
|
|
||||||||||||||
| # Remove consul from experimental section (if present) | ||||||||||||||
| sed -i '/enable_consul = true/d' fly.toml | ||||||||||||||
|
|
||||||||||||||
|
||||||||||||||
| # Add auto-scaling configuration to services section | ||||||||||||||
| # Find the [[services]] section and add auto-scaling after internal_port | ||||||||||||||
| awk ' | ||||||||||||||
| /^\[\[services\]\]/ { in_services = 1 } | ||||||||||||||
| /^ internal_port = / && in_services { | ||||||||||||||
| print $0 | ||||||||||||||
| print " auto_stop_machines = true" | ||||||||||||||
| print " auto_start_machines = true" | ||||||||||||||
| print " min_machines_running = 0" | ||||||||||||||
| print " processes = [\"app\"]" | ||||||||||||||
| in_services = 0 | ||||||||||||||
| next | ||||||||||||||
| } | ||||||||||||||
| { print } | ||||||||||||||
| ' fly.toml > fly.toml.tmp && mv fly.toml.tmp fly.toml | ||||||||||||||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||
|
|
||||||||||||||
| # Copy and modify litefs.yml for PR preview (standalone, no consul) | ||||||||||||||
| cp other/litefs.yml other/litefs.yml.backup | ||||||||||||||
|
|
||||||||||||||
| # Replace consul lease with static lease for PR preview isolation | ||||||||||||||
| # This makes each PR preview a standalone instance | ||||||||||||||
| sed -i '/^lease:/,/^exec:/c\ | ||||||||||||||
| lease:\ | ||||||||||||||
| type: static\ | ||||||||||||||
| \ | ||||||||||||||
| exec:' other/litefs.yml | ||||||||||||||
|
||||||||||||||
| sed -i '/^lease:/,/^exec:/c\ | |
| lease:\ | |
| type: static\ | |
| \ | |
| exec:' other/litefs.yml | |
| yq -i 'del(.lease) | .lease.type="static"' other/litefs.yml |
🧰 Tools
🪛 actionlint (1.7.7)
64-64: could not parse as YAML: yaml: line 64: could not find expected ':'
(syntax-check)
🪛 YAMLlint (1.37.1)
[error] 65-65: syntax error: could not find expected ':'
(syntax)
🤖 Prompt for AI Agents
In .github/workflows/pr-preview.yml around lines 63 to 67, the multi-line sed
replacement breaks the YAML syntax causing a parse error. To fix this, replace
the sed command with a yq command to perform the YAML modification safely. This
avoids breaking the run scalar block and prevents brittle text manipulation by
using proper YAML-aware editing.
Uh oh!
There was an error while loading. Please reload this page.