Skip to content

Commit f254cde

Browse files
JacobCoffeeclaude
andcommitted
feat: add Railway bot service deployment workflow
- Add GHA workflow to build bot Docker image and push to GHCR - Add railway.json config for bot service - Triggers on changes to bot code, byte-common, or dependencies Setup required: 1. Create "byte-bot" service in Railway dashboard 2. Set Root Directory to: services/bot 3. Add RAILWAY_BOT_SERVICE_ID secret to GitHub 4. Copy env vars from API service (DISCORD_TOKEN, etc.) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 47437cf commit f254cde

File tree

2 files changed

+107
-0
lines changed

2 files changed

+107
-0
lines changed

.github/workflows/deploy-bot.yml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: Deploy Bot
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- 'services/bot/**'
8+
- 'packages/byte-common/**'
9+
- 'pyproject.toml'
10+
- 'uv.lock'
11+
- '.github/workflows/deploy-bot.yml'
12+
workflow_dispatch:
13+
14+
concurrency:
15+
group: deploy-bot-${{ github.ref }}
16+
cancel-in-progress: true
17+
18+
env:
19+
REGISTRY: ghcr.io
20+
IMAGE_NAME: ${{ github.repository }}-bot
21+
22+
jobs:
23+
build-and-push:
24+
name: Build & Push
25+
runs-on: ubuntu-latest
26+
permissions:
27+
contents: read
28+
packages: write
29+
outputs:
30+
image: ${{ steps.meta.outputs.tags }}
31+
digest: ${{ steps.build.outputs.digest }}
32+
33+
steps:
34+
- name: Checkout
35+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
36+
with:
37+
persist-credentials: false
38+
39+
- name: Set up Docker Buildx
40+
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0
41+
42+
- name: Log in to Container Registry
43+
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
44+
with:
45+
registry: ${{ env.REGISTRY }}
46+
username: ${{ github.actor }}
47+
password: ${{ secrets.GITHUB_TOKEN }}
48+
49+
- name: Extract metadata
50+
id: meta
51+
uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804 # v5.7.0
52+
with:
53+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
54+
tags: |
55+
type=sha,prefix=
56+
type=raw,value=latest,enable={{is_default_branch}}
57+
58+
- name: Build and push
59+
id: build
60+
uses: docker/build-push-action@14487ce63c7a62a4a324b0bfb37086795e31c6c1 # v6.16.0
61+
with:
62+
context: .
63+
file: services/bot/Dockerfile
64+
push: true
65+
tags: ${{ steps.meta.outputs.tags }}
66+
labels: ${{ steps.meta.outputs.labels }}
67+
cache-from: type=gha
68+
cache-to: type=gha,mode=max
69+
platforms: linux/amd64
70+
71+
deploy:
72+
name: Deploy to Railway
73+
needs: build-and-push
74+
runs-on: ubuntu-latest
75+
permissions:
76+
contents: read
77+
environment:
78+
name: production
79+
80+
steps:
81+
- name: Deploy to Railway
82+
env:
83+
RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }}
84+
run: |
85+
echo "Image: ghcr.io/${{ github.repository }}-bot:latest"
86+
echo "Digest: ${{ needs.build-and-push.outputs.digest }}"
87+
88+
npm install -g @railway/cli
89+
90+
if [ -n "${{ secrets.RAILWAY_BOT_SERVICE_ID }}" ]; then
91+
railway redeploy --service "${{ secrets.RAILWAY_BOT_SERVICE_ID }}" --yes
92+
else
93+
echo "::warning::RAILWAY_BOT_SERVICE_ID secret not set. Create a bot service in Railway and add the service ID."
94+
exit 1
95+
fi

services/bot/railway.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"$schema": "https://schema.up.railway.app/railway.schema.json",
3+
"build": {
4+
"builder": "DOCKERFILE",
5+
"dockerfilePath": "services/bot/Dockerfile"
6+
},
7+
"deploy": {
8+
"startCommand": "python -m byte_bot",
9+
"restartPolicyType": "ON_FAILURE",
10+
"restartPolicyMaxRetries": 10
11+
}
12+
}

0 commit comments

Comments
 (0)