# Deploy

Deploy Rails applications to Railway.

- Repository: https://github.com/clacky-ai/openclacky (1209 stars)
- Category: DevOps
- License: MIT
- Last updated: 2026-10-30
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add clacky-ai/openclacky --skill deploy -g -a claude-code -y`
Codex: `npx skills add clacky-ai/openclacky --skill deploy -g -a codex -y`
Cursor: `npx skills add clacky-ai/openclacky --skill deploy -g -a cursor -y`
Gemini CLI: `npx skills add clacky-ai/openclacky --skill deploy -g -a gemini-cli -y`

## Description

Deploy Rails applications to Railway. Handles first-time setup and re-deploys idempotently using Railway CLI. Trigger on: "deploy", "deploy to railway", "railway deploy", "发布", "部署", "上线".

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# Deploy Rails App to Railway

Deploy the current Rails project to Railway using the Railway CLI. Works for both first-time deploys and re-deploys.

## Prerequisites Check

Before starting, verify:

```bash
# 1. Railway CLI installed?
railway --version

# 2. Logged in?
railway whoami
```

If not logged in, instruct the user:
```
Please run: railway login
Then retry deployment.
```

## Step 0: Prepare for Linux Build

Railway runs on Linux. Ensure Gemfile.lock includes the linux platform:

```bash
bundle lock --add-platform x86_64-linux
```

If the project uses a `Dockerfile` builder (check `railway.toml` for `builder = "DOCKERFILE"`), no `Procfile` is needed, skip creating one.

Only create a `Procfile` if there is no Dockerfile:
```
web: bundle exec puma -C config/puma.rb
```

## Step 1: Check Link Status → Deploy Immediately if Already Linked

**First: check if already linked:**
```bash
railway status 2>&1
```

**If output contains `Project:` → project is already linked.**
Skip Steps 2, 5 entirely and jump to Step 6 (Deploy).

**If output contains "not linked" or an error → not linked yet.**
Try linking to an existing project first, list available projects:
```bash
railway list 2>&1 | grep -i "<app-name>"
```

If a matching project is found, link it:
```bash
railway link --project <project-name> --service <service-name> 2>&1
```

Only if no existing project is found, init a new one:
```bash
railway init -n <app-name>
```
The `app-name` should match the current directory name (e.g., `my-rails-app`).

**⚠️ NEVER run `railway init` when already linked or when an existing project exists.**
It silently creates a brand-new Railway project. If this happens by mistake:
1. Find the correct project name from `railway list`
2. Re-link: `railway link --project <project-name> --service <service-name>`

## Step 2: Set Environment Variables

Set required Rails production variables. Use `--skip-deploys` to avoid triggering premature deploys:

The rest: https://github.com/clacky-ai/openclacky/blob/HEAD/lib/clacky/default_skills/deploy/SKILL.md
