Skip to content

Commit 8cf32ae

Browse files
committed
feat: setup CI/CD
1 parent 96bc0b5 commit 8cf32ae

6 files changed

Lines changed: 107 additions & 1 deletion

File tree

.github/workflows/ci.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Build and Test
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
ci:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Setup pnpm
17+
uses: pnpm/action-setup@v4
18+
with:
19+
version: 10
20+
run_install: false
21+
22+
- name: Setup Node.js
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version: 22
26+
27+
- name: Get pnpm store directory
28+
shell: bash
29+
run: echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
30+
31+
- name: Cache pnpm store
32+
uses: actions/cache@v4
33+
with:
34+
path: ${{ env.STORE_PATH }}
35+
key: pnpm-store-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
36+
restore-keys: pnpm-store-${{ runner.os }}-
37+
38+
- name: Install dependencies
39+
run: pnpm install --frozen-lockfile
40+
41+
- name: Lint
42+
run: pnpm --filter backend lint
43+
44+
- name: Type check
45+
run: pnpm --filter backend typecheck
46+
47+
- name: Test
48+
run: pnpm --filter backend test

README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,45 @@ Progression: Kōhai → Senpai → Sensei based on peer recognition.
1010

1111
### [Blockchain Roles](./spec/BLOCKCHAIN.md)
1212
Wallet-linked roles based on Starknet state (NFT ownership, token holdings, etc.).
13+
14+
## Deployment
15+
16+
The bot uses GitHub Actions for CI and Railway for deployment.
17+
Pushes to `main` automatically deploy after CI passes.
18+
19+
### Setup
20+
21+
1. **Create Railway Project**
22+
- Go to [railway.app](https://railway.app) and sign in with GitHub
23+
- Click "New Project" → "Deploy from GitHub repo"
24+
- Select the `daimyo` repository
25+
26+
2. **Set Environment Variables**
27+
- In Railway, go to your service → Variables
28+
- Add the following (see `backend/.env.example` for reference):
29+
```
30+
DISCORD_BOT_TOKEN=<your token>
31+
DISCORD_GUILD_ID=<your guild id>
32+
DISCORD_CLIENT_ID=<your client id>
33+
DOJO_EMOJI_NAME=dojo
34+
KOHAI_ROLE_ID=<role id>
35+
SENPAI_ROLE_ID=<role id>
36+
SENSEI_ROLE_ID=<role id>
37+
DATABASE_PATH=/data/daimyo.db
38+
DECAY_WINDOW_DAYS=360
39+
SENPAI_REACTION_THRESHOLD=50
40+
SENPAI_UNIQUE_PERCENT=0.10
41+
SENSEI_REACTION_THRESHOLD=30
42+
SENSEI_UNIQUE_PERCENT=0.20
43+
```
44+
45+
3. **Create Volume for Database**
46+
- In Railway, click your service → Settings → Volumes
47+
- Add a volume with mount path `/data`
48+
- This persists the SQLite database across deployments
49+
50+
4. **(Optional) GitHub Branch Protection**
51+
- Go to GitHub repo → Settings → Branches
52+
- Add rule for `main` branch
53+
- Enable "Require status checks to pass before merging"
54+
- Select the `ci` check

backend/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"type": "module",
77
"scripts": {
88
"dev": "tsx watch src/index.ts",
9-
"build": "tsc",
9+
"build": "tsc -p tsconfig.build.json",
10+
"typecheck": "tsc --noEmit -p tsconfig.build.json",
1011
"start": "node dist/index.js",
1112
"deploy-commands": "tsx src/deploy-commands.ts",
1213
"lint": "eslint .",

backend/tsconfig.build.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"include": ["src/**/*"],
4+
"exclude": ["node_modules", "dist", "__tests__"]
5+
}

pnpm-workspace.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
packages:
2+
- backend

railway.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[build]
2+
builder = "nixpacks"
3+
buildCommand = "pnpm install --frozen-lockfile && pnpm --filter backend build"
4+
5+
[deploy]
6+
startCommand = "pnpm --filter backend start"
7+
restartPolicyType = "ON_FAILURE"
8+
restartPolicyMaxRetries = 3

0 commit comments

Comments
 (0)