Skip to content

Commit 49df824

Browse files
committed
feat: setup CI/CD
1 parent 96bc0b5 commit 49df824

9 files changed

Lines changed: 9280 additions & 3 deletions

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

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
/.pnp
66
.pnp.js
77
.pnpm-store
8-
pnpm-lock.yaml
98

109
# testing
1110
/coverage

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: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
{
2-
"name": "daimyo-backend",
2+
"name": "backend",
33
"version": "1.0.0",
44
"description": "Discord reputation bot for Dojo community",
55
"main": "dist/index.js",
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 .",

0 commit comments

Comments
 (0)