Skip to content

Commit 6eeb1a0

Browse files
committed
chore: configured ci
1 parent d0d9358 commit 6eeb1a0

6 files changed

Lines changed: 166 additions & 6 deletions

File tree

.github/workflows/ci.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
changes:
11+
runs-on: ubuntu-latest
12+
outputs:
13+
web: ${{ steps.filter.outputs.web }}
14+
api: ${{ steps.filter.outputs.api }}
15+
sdk: ${{ steps.filter.outputs.sdk }}
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: dorny/paths-filter@v3
19+
id: filter
20+
with:
21+
filters: |
22+
web:
23+
- 'apps/web/**'
24+
- 'packages/ui/**'
25+
api:
26+
- 'apps/api/**'
27+
- 'packages/db/**'
28+
sdk:
29+
- 'sdk/**'
30+
- 'packages/evaluation-core/**'
31+
test:
32+
needs: changes
33+
runs-on: ubuntu-latest
34+
steps:
35+
- uses: actions/checkout@v4
36+
- uses: pnpm/action-setup@v2
37+
with:
38+
version: 9
39+
- uses: actions/setup-node@v4
40+
with:
41+
node-version: 20
42+
cache: 'pnpm'
43+
- run: pnpm install
44+
- run: pnpm lint
45+
- run: pnpm check-types
46+
- name: Build All (with dummy DB)
47+
run: pnpm build
48+
env:
49+
DATABASE_URL: "postgresql://test:test@localhost:5432/test"
50+
deploy-trigger:
51+
needs: [test, changes]
52+
if: github.ref == 'refs/heads/main'
53+
runs-on: ubuntu-latest
54+
steps:
55+
- name: Trigger Frontend
56+
if: needs.changes.outputs.web == 'true' || needs.changes.outputs.sdk == 'true'
57+
uses: peter-evans/repository-dispatch@v2
58+
with:
59+
token: ${{ secrets.GITHUB_TOKEN }}
60+
event-type: deploy-frontend
61+
62+
- name: Trigger API
63+
if: needs.changes.outputs.api == 'true'
64+
uses: peter-evans/repository-dispatch@v2
65+
with:
66+
token: ${{ secrets.GITHUB_TOKEN }}
67+
event-type: deploy-api
68+
69+
- name: Trigger Worker
70+
if: needs.changes.outputs.api == 'true'
71+
uses: peter-evans/repository-dispatch@v2
72+
with:
73+
token: ${{ secrets.GITHUB_TOKEN }}
74+
event-type: deploy-worker

.github/workflows/deploy-api.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Deploy API
2+
3+
on:
4+
repository_dispatch:
5+
types: [deploy-api]
6+
7+
jobs:
8+
deploy:
9+
name: Deploy API to Render
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Trigger Render Deploy
13+
uses: johnnymanz/github-render-deploy@v1.0.0
14+
with:
15+
service-id: ${{ secrets.RENDER_API_SERVICE_ID }}
16+
api-key: ${{ secrets.RENDER_API_KEY }}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Deploy Frontend
2+
3+
on:
4+
repository_dispatch:
5+
types: [deploy-frontend]
6+
7+
jobs:
8+
deploy:
9+
name: Deploy to Vercel
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout Repo
13+
uses: actions/checkout@v4
14+
15+
- name: Setup pnpm
16+
uses: pnpm/action-setup@v2
17+
with:
18+
version: 9
19+
20+
- name: Setup Node
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: 20
24+
cache: 'pnpm'
25+
26+
- name: Install Dependencies
27+
run: pnpm install
28+
29+
- name: Build Frontend
30+
run: pnpm turbo run build --filter=web
31+
32+
- name: Deploy to Vercel
33+
uses: amondnet/vercel-action@v25
34+
with:
35+
vercel-token: ${{ secrets.VERCEL_TOKEN }}
36+
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }}
37+
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }}
38+
working-directory: ./apps/web
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Deploy Worker
2+
3+
on:
4+
repository_dispatch:
5+
types: [deploy-worker]
6+
7+
jobs:
8+
deploy:
9+
name: Deploy Worker to Render
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Trigger Render Deploy
13+
uses: johnnymanz/github-render-deploy@v1.0.0
14+
with:
15+
service-id: ${{ secrets.RENDER_WORKER_SERVICE_ID }}
16+
api-key: ${{ secrets.RENDER_API_KEY }}

.github/workflows/release.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,22 @@ on:
44
push:
55
branches:
66
- main
7+
paths:
8+
- 'sdk/**'
9+
- 'packages/evaluation-core/**'
10+
- '.changeset/**'
711

812
concurrency: ${{ github.workflow }}-${{ github.ref }}
913

1014
jobs:
1115
release:
12-
name: Release
16+
name: Release SDKs
1317
runs-on: ubuntu-latest
1418
steps:
1519
- name: Checkout Repo
1620
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
1723

1824
- name: Setup pnpm
1925
uses: pnpm/action-setup@v2
@@ -29,11 +35,16 @@ jobs:
2935
- name: Install Dependencies
3036
run: pnpm install
3137

38+
- name: Build SDKs Only
39+
run: pnpm turbo run build --filter="@flagix/js-sdk" --filter="@flagix/react" --filter="@flagix/evaluation-core"
40+
3241
- name: Create Release Pull Request or Publish to npm
3342
id: changesets
3443
uses: changesets/action@v1
3544
with:
36-
publish: pnpm release
45+
publish: pnpm changeset publish
46+
commit: 'chore: release SDKs'
47+
title: 'chore: release SDKs'
3748
env:
3849
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3950
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

turbo.json

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,27 @@
55
"build": {
66
"dependsOn": ["^build", "^db:generate"],
77
"inputs": ["$TURBO_DEFAULT$", ".env*"],
8-
"outputs": [".next/**", "!.next/cache/**", "dist/**"],
9-
"env": ["DATABASE_URL"]
8+
"outputs": [".next/**", "!.next/cache/**", "dist/**", "build/**"],
9+
"env": ["DATABASE_URL", "NODE_ENV", "NEXT_PUBLIC_*"]
1010
},
1111
"db:generate": {
1212
"cache": false,
1313
"env": ["DATABASE_URL"]
1414
},
1515
"lint": {
16-
"dependsOn": ["^lint"]
16+
"outputs": []
1717
},
1818
"check-types": {
19-
"dependsOn": ["^check-types"]
19+
"dependsOn": ["^build"],
20+
"outputs": []
2021
},
2122
"dev": {
2223
"cache": false,
2324
"persistent": true
25+
},
26+
"db:deploy": {
27+
"cache": false,
28+
"interactive": true
2429
}
2530
}
2631
}

0 commit comments

Comments
 (0)