Skip to content

[Price Compare] Step 13: GitHub Actions deploy workflow for Railway #84

@frankieboxx

Description

@frankieboxx

Step 13 — GitHub Actions Deploy Workflow for Railway

Create .github/workflows/deploy.yml — triggered on push to main (after CI passes), deploys to Railway.

Requirements:

  • Railway project ID: c9eeed53-f5d1-4c5e-9eae-68793b4691c9
  • Crawler service ID: 74f04ed3-edf6-4293-a47c-82daad7dffa7
  • Needs RAILWAY_TOKEN secret in GitHub repo settings
  • Should only deploy when CI build succeeds (use needs: build)

Workflow:

name: Deploy to Railway

on:
  push:
    branches: ["main"]

jobs:
  build:
    uses: ./.github/workflows/ci.yml

  deploy:
    needs: build
    runs-on: ubuntu-24.04
    if: github.ref == 'refs/heads/main'
    steps:
      - uses: actions/checkout@v4
      - name: Install Railway CLI
        run: npm install -g @railway/cli
      - name: Deploy to Railway
        env:
          RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }}
        run: railway up --service ${{ vars.RAILWAY_SERVICE_ID || '74f04ed3-edf6-4293-a47c-82daad7dffa7' }}

Setup steps:

  1. Generate Railway API token: railway loginrailway tokens create
  2. Add RAILWAY_TOKEN as GitHub Actions secret in repo settings
  3. Optionally add RAILWAY_SERVICE_ID as GitHub Actions variable
  4. Existing CI workflow (ci.yml) stays as-is for lint/type checks

Files: .github/workflows/deploy.yml
Priority: P3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions