Railway Provider
Deploy preview environments to Railway services.
How it works
- Build: Previewops creates a synthetic image tag pointing at the source commit. Railway builds from the repo's Dockerfile using its own infrastructure.
- Deploy: creates a Railway service within your project (or re-deploys for the same PR). Polls until deployment reaches
SUCCESSstatus. - Delete: deletes the Railway service.
- List: lists all services in the project that match the
prev-{owner}-{repo}name prefix.
Prerequisites
- A Railway account with an existing project and environment.
- A Railway API token.
Step 1 — Create a Railway project
- Go to railway.app → New Project.
- Note the Project ID from the project's settings URL or the Settings → General panel.
- Note the Environment ID (found in Settings → Environments → click environment → ID).
Step 2 — Get a Railway API token
- Go to Account Settings → Tokens → Create Token.
- Give it a descriptive name (e.g.
previewops). - Copy the token and store it as
RAILWAY_API_TOKENin the Previewops secrets.
Step 3 — Configure the repo
provider: railway
providerConfig:
projectId: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx # required — Railway project UUID
environmentId: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx # required — Railway environment UUID
Both IDs are UUIDs. You can find them in the Railway dashboard URL:
https://railway.app/project/<projectId>/settings
Step 4 — Verify
Comment /validate-previewops on any open PR. The bot calls { me { id name } } against the Railway GraphQL API and reports the authenticated account name.
Troubleshooting
| Error | Fix |
|---|---|
RAILWAY_API_TOKEN environment variable is required |
Set the token in your secret store |
Railway GraphQL errors: ... |
Token is expired or lacks project permissions — regenerate |
Deployment stuck in BUILDING |
Railway quota may be exhausted; check the Railway dashboard |