Skip to content

Commit ba64244

Browse files
authored
Merge pull request #350 from Emins25/codex/bounty-167
ci: add backend build-test-deploy workflow
2 parents 74da90f + 1ed7f44 commit ba64244

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

.github/workflows/backend.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Backend CI/CD
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- master
8+
paths:
9+
- "backend/**"
10+
- ".github/workflows/backend.yml"
11+
pull_request:
12+
branches:
13+
- main
14+
- master
15+
paths:
16+
- "backend/**"
17+
- ".github/workflows/backend.yml"
18+
workflow_dispatch:
19+
20+
permissions:
21+
contents: read
22+
23+
jobs:
24+
build-and-test:
25+
name: Build and Test Backend
26+
runs-on: ubuntu-latest
27+
defaults:
28+
run:
29+
working-directory: backend
30+
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@v4
34+
35+
- name: Setup pnpm
36+
uses: pnpm/action-setup@v4
37+
with:
38+
version: 9
39+
40+
- name: Setup Node.js
41+
uses: actions/setup-node@v4
42+
with:
43+
node-version: "20"
44+
cache: "pnpm"
45+
cache-dependency-path: backend/pnpm-lock.yaml
46+
47+
- name: Install dependencies
48+
run: pnpm install --frozen-lockfile
49+
50+
- name: Build
51+
run: pnpm run build
52+
53+
- name: Test
54+
run: pnpm run test -- --ci
55+
56+
deploy:
57+
name: Deploy Backend
58+
needs: build-and-test
59+
runs-on: ubuntu-latest
60+
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
61+
62+
steps:
63+
- name: Deploy to Railway (deploy hook)
64+
if: ${{ secrets.RAILWAY_DEPLOY_HOOK_URL != '' }}
65+
env:
66+
RAILWAY_DEPLOY_HOOK_URL: ${{ secrets.RAILWAY_DEPLOY_HOOK_URL }}
67+
run: curl -fsSL -X POST "$RAILWAY_DEPLOY_HOOK_URL"
68+
69+
- name: Skip deploy when hook is missing
70+
if: ${{ secrets.RAILWAY_DEPLOY_HOOK_URL == '' }}
71+
run: echo "No RAILWAY_DEPLOY_HOOK_URL configured. Skipping deploy."

0 commit comments

Comments
 (0)