Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 98 additions & 0 deletions .github/workflows/deploy-lit-payments.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# Deploy lit-payments to Railway
#
# Mirrors the lit-static release flow (see deploy-static.yml /
# deploy-prod-3-static.yml), but the deploy target is Railway instead of
# Cloudflare Pages:
#
# * push to `main` -> Railway "staging" environment
# * push of a `v*` tag -> Railway "production" environment
#
# Deployment uses the Railway CLI (`railway up`) authenticated with an
# environment-scoped Railway *project token* passed as RAILWAY_TOKEN. A project
# token encodes both the Railway project and its environment, so there is no
# `railway link` step — we only pass the service name.
#
# lit-payments needs the repo ROOT as its build context: its Dockerfile COPYs
# the sibling `lit-billing-core` crate. So `railway up` runs from the repo root,
# and the Railway service must be pre-configured (in the Railway dashboard) with:
# * Root directory / build context: repo root (/)
# * Config file path: lit-payments/railway.json
# (See lit-payments/README.md → "Deploy to Railway".)
#
# Required repository secrets:
# RAILWAY_TOKEN_PAYMENTS_STAGING Railway project token — lit-payments
# project, "staging" environment.
# RAILWAY_TOKEN_PAYMENTS_PRODUCTION Railway project token — lit-payments
# project, "production" environment.
#
# Optional repository variables (defaults shown):
# RAILWAY_PAYMENTS_SERVICE Railway service name (default: lit-payments)

name: Deploy lit-payments (Railway)

on:
push:
branches: [main]
tags: ['v*']
workflow_dispatch:
inputs:
environment:
description: 'Railway environment to deploy'
required: true
default: staging
type: choice
options:
- staging
- production

concurrency:
group: deploy-lit-payments-${{ github.ref }}
cancel-in-progress: false

permissions:
contents: read

jobs:
deploy-staging:
if: >
(github.event_name == 'push' && github.ref == 'refs/heads/main') ||
(github.event_name == 'workflow_dispatch' && inputs.environment == 'staging')
runs-on: self-hosted
environment: staging
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install Railway CLI
run: npm install -g @railway/cli@5.57.2

- name: Deploy to Railway (staging)
# Build context = repo root so the Dockerfile can reach lit-billing-core.
env:
RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN_PAYMENTS_STAGING }}
run: railway up --ci --service "${{ vars.RAILWAY_PAYMENTS_SERVICE || 'lit-payments' }}"

deploy-production:
if: >
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')) ||
(github.event_name == 'workflow_dispatch' && inputs.environment == 'production')
runs-on: self-hosted
environment: production
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install Railway CLI
run: npm install -g @railway/cli@5.57.2

- name: Deploy to Railway (production)
# Build context = repo root so the Dockerfile can reach lit-billing-core.
env:
RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN_PAYMENTS_PRODUCTION }}
run: railway up --ci --service "${{ vars.RAILWAY_PAYMENTS_SERVICE || 'lit-payments' }}"
102 changes: 102 additions & 0 deletions .github/workflows/deploy-lit-triggers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# Deploy lit-triggers to Railway
#
# Mirrors the lit-static release flow (see deploy-static.yml /
# deploy-prod-3-static.yml), but the deploy target is Railway instead of
# Cloudflare Pages:
#
# * push to `main` -> Railway "staging" environment
# * push of a `v*` tag -> Railway "production" environment
#
# Deployment uses the Railway CLI (`railway up`) authenticated with an
# environment-scoped Railway *project token* passed as RAILWAY_TOKEN. A project
# token encodes both the Railway project and its environment, so there is no
# `railway link` step — we only pass the service name.
#
# lit-triggers is self-contained: its Dockerfile `COPY . .`s from the
# `lit-triggers/` directory, so `railway up` runs from that directory (Railway
# service root = lit-triggers, config = lit-triggers/railway.json).
# (See lit-triggers/README.md → "Railway deployment".)
#
# Required repository secrets:
# RAILWAY_TOKEN_TRIGGERS_STAGING Railway project token — lit-triggers
# project, "staging" environment.
# RAILWAY_TOKEN_TRIGGERS_PRODUCTION Railway project token — lit-triggers
# project, "production" environment.
#
# Optional repository variables (defaults shown):
# RAILWAY_TRIGGERS_SERVICE Railway service name (default: lit-triggers)

name: Deploy lit-triggers (Railway)

on:
push:
branches: [main]
tags: ['v*']
workflow_dispatch:
inputs:
environment:
description: 'Railway environment to deploy'
required: true
default: staging
type: choice
options:
- staging
- production

concurrency:
group: deploy-lit-triggers-${{ github.ref }}
cancel-in-progress: false

permissions:
contents: read

jobs:
deploy-staging:
if: >
(github.event_name == 'push' && github.ref == 'refs/heads/main') ||
(github.event_name == 'workflow_dispatch' && inputs.environment == 'staging')
runs-on: self-hosted
environment: staging
defaults:
run:
working-directory: lit-triggers
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install Railway CLI
run: npm install -g @railway/cli@5.57.2

- name: Deploy to Railway (staging)
# Build context = lit-triggers/ to match the Dockerfile's `COPY . .`.
env:
RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN_TRIGGERS_STAGING }}
run: railway up --ci --service "${{ vars.RAILWAY_TRIGGERS_SERVICE || 'lit-triggers' }}"

deploy-production:
if: >
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')) ||
(github.event_name == 'workflow_dispatch' && inputs.environment == 'production')
runs-on: self-hosted
environment: production
defaults:
run:
working-directory: lit-triggers
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install Railway CLI
run: npm install -g @railway/cli@5.57.2

- name: Deploy to Railway (production)
# Build context = lit-triggers/ to match the Dockerfile's `COPY . .`.
env:
RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN_TRIGGERS_PRODUCTION }}
run: railway up --ci --service "${{ vars.RAILWAY_TRIGGERS_SERVICE || 'lit-triggers' }}"
19 changes: 19 additions & 0 deletions lit-payments/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,25 @@ railway link # choose or create the lit-payments project
railway up # from repo root; service config path should be lit-payments/railway.json
```

### CI/CD (GitHub Actions)

`.github/workflows/deploy-lit-payments.yml` deploys automatically via the
Railway CLI, mirroring the `lit-static` release flow:

- push to `main` → Railway **staging** environment
- push of a `v*` tag → Railway **production** environment

It runs `railway up` from the repo root (so the Dockerfile can reach
`lit-billing-core`) and selects the service with `--service`. Auth uses
environment-scoped Railway **project tokens**, so no `railway link` is needed.

Required repo secrets:

- `RAILWAY_TOKEN_PAYMENTS_STAGING` — project token, `staging` environment
- `RAILWAY_TOKEN_PAYMENTS_PRODUCTION` — project token, `production` environment

Optional repo variable: `RAILWAY_PAYMENTS_SERVICE` (defaults to `lit-payments`).

### 2. Add Postgres

Use Railway's Postgres plugin for the cheapest/simple path:
Expand Down
16 changes: 16 additions & 0 deletions lit-triggers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,22 @@ Create a Railway project with:
3. The web service root directory set to `lit-triggers`.
4. App sleeping disabled. `lit-triggers/railway.json` sets `sleepApplication: false`; keep it disabled in the Railway UI too because scheduled and chain-event triggers rely on a continuously running worker.

### CI/CD (GitHub Actions)

`.github/workflows/deploy-lit-triggers.yml` deploys automatically via the Railway CLI, mirroring the `lit-static` release flow:

- push to `main` → Railway **staging** environment
- push of a `v*` tag → Railway **production** environment

It runs `railway up` from the `lit-triggers/` directory (matching the service root) and selects the service with `--service`. Auth uses environment-scoped Railway **project tokens**, so no `railway link` is needed.

Required repo secrets:

- `RAILWAY_TOKEN_TRIGGERS_STAGING` — project token, `staging` environment
- `RAILWAY_TOKEN_TRIGGERS_PRODUCTION` — project token, `production` environment

Optional repo variable: `RAILWAY_TRIGGERS_SERVICE` (defaults to `lit-triggers`).

Set the web service variables before deploying:

```bash
Expand Down
Loading