Spin up a Fly.io preview environment for every pull request

The moment a pull request opens, we launch a live preview of that branch on Fly.io and post the link right on the PR and in your team's Slack channel.

Agentic Task
Fly.ioGitHubSlack BotEngineeringNotifications & Alerts
PromptCreate

Trigger this workflow with a webhook whenever a pull request is opened in my GitHub repository. Read the pull request number, the head branch name, and the repository from the webhook payload so the rest of the run can reference them.

Let me configure two settings up front: the name of my Fly.io preview app that should host the branch, and the container image the Machine should boot from. Use those two values everywhere below.

When the pull request opens, call the Fly.io Create Machine operation in my preview app to launch a Machine for this branch, booting it from the configured image. Tag the Machine with the pull request number in the Machine metadata so I can always tell which preview belongs to which pull request.

Fly.io can refuse to place a Machine when the target region is out of capacity, and the API does not queue the request, so you own the retries. If Create Machine cannot place the Machine, use the Fly.io Get Placements operation to see which regions currently have room, then retry Create Machine in a fallback region. Work through a few sensible regions before giving up. If every attempt fails, post a comment on the pull request explaining that no region had capacity right now.

Once the Machine is created, use the Fly.io Wait for State operation to block until it reaches the started state, so I only share the preview once it is actually running.

When the Machine is running, build the preview URL from the configured preview app name (the app's public Fly.io URL) and post it back onto the pull request using the GitHub Create an Issue Comment operation, addressed to the pull request number. Keep the comment short: the preview link plus one line telling reviewers they can click straight through.

Then send a short heads-up to my team's Slack channel with the Slack Bot Send a Message operation, including the pull request title, its number, and the preview link, so the team can jump straight into review.

Additional information

What does this prompt do?
  • Watches your repository and reacts the moment a pull request is opened, with nothing to kick off by hand.
  • Launches a fresh, isolated preview of that branch on Fly.io so reviewers can click through the actual running app instead of imagining the change.
  • Waits until the preview is fully up, then drops the link as a comment on the pull request and sends a heads-up to your team's Slack channel.
  • Automatically retries in another region if the first location is out of capacity, so the preview still comes up instead of quietly failing.
What do I need to use this?
  • A Fly.io account with a preview app set aside to host branch builds.
  • A container image for your app that the preview should boot from.
  • A GitHub repository where teammates open pull requests.
  • A Slack workspace and a channel where the review heads-up should land.
How can I customize it?
  • Point it at the Fly.io app you want previews to run in.
  • Choose which container image each preview boots from.
  • Change which Slack channel gets pinged and reword the message to match your team's voice.

Frequently asked questions

When does the preview get created?
As soon as someone opens a pull request. There is nothing to trigger by hand, and it works for every new PR in the repository you connect.
What happens if the first region is out of capacity?
The workflow checks where there is room and automatically tries another region, so the preview still comes up instead of failing silently.
Where do I find the preview link?
It is posted as a comment right on the pull request, and also sent to your team's Slack channel so reviewers can click straight through.
Can I use my own app image?
Yes. You choose the container image each preview boots from when you set the workflow up, and you can change it any time.
Does the preview wait until the app is actually running?
Yes. We hold off on sharing the link until the preview has fully started, so reviewers never click into something that is still booting.

Related templates

Daily Braintree declined-payment recovery digest to Slack

Every weekday at 8am, your billing team gets a Slack rundown of yesterday's failed Braintree charges, the revenue at risk, and who to chase first.

Braintree
Slack Bot
Agentic Task
Weekday Azure DevOps sprint standup digest in Slack

Every weekday morning, roll up your sprint's work items into a clear per-person standup summary and post it to your team's Slack channel before you meet.

Azure DevOps
Slack Bot
Agentic Task
Track new Braintree disputes before the deadline slips

Every three hours we scan Braintree for new disputes and chargebacks, open a tracked ticket with a tailored evidence checklist, and alert your team in Slack before the response deadline slips.

Braintree
Zendesk
Slack Bot
Agentic Task
Daily Databricks data health check with Slack alerts

Every weekday morning we check your most important Databricks tables for freshness and data problems, and ping Slack only when something actually looks wrong.

Databricks
Slack Bot
Agentic Task
Monday morning employee breach exposure briefing in Slack

Every Monday, automatically find which employee accounts on your company domain turned up in data breaches and get a plain-English briefing in Slack.

Have I Been Pwned
Slack Bot
Agentic Task
Instant Slack alert when an Azure DevOps build fails

When a pipeline build fails, we post a tight Slack card naming who pushed, the likely cause, and a link to the build so on-call can triage in seconds.

Azure DevOps
Slack Bot
Agentic Task

Give every pull request its own live preview.

Open a PR and get a working preview link on the pull request and in Slack, without touching your terminal.