Skip to content

Commit 1a36788

Browse files
authored
Merge pull request #88 from sgcarstrends/87-setup-monorepo
Setup monorepo
2 parents 82a7547 + edce2af commit 1a36788

File tree

101 files changed

+7248
-693
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+7248
-693
lines changed

.github/workflows/deploy-api.yml

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Deploy API
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
environment:
7+
description: "GitHub environment name"
8+
required: true
9+
type: string
10+
sst-stage:
11+
description: "SST deployment stage"
12+
required: true
13+
type: string
14+
15+
permissions:
16+
id-token: write
17+
contents: read
18+
packages: read
19+
20+
jobs:
21+
deploy-api:
22+
runs-on: ubuntu-latest
23+
environment: ${{ inputs.environment }}
24+
# Concurrency group name ensures concurrent workflow runs wait for any in-progress job to finish
25+
concurrency:
26+
group: api-${{ inputs.environment }}-${{ github.ref }}
27+
28+
steps:
29+
- uses: actions/checkout@v4
30+
- uses: pnpm/action-setup@v4
31+
with:
32+
version: '10.4.1'
33+
- uses: actions/setup-node@v4
34+
with:
35+
node-version: '20'
36+
cache: "pnpm"
37+
38+
- name: Install dependencies
39+
run: pnpm install
40+
41+
- uses: aws-actions/configure-aws-credentials@v4
42+
with:
43+
role-to-assume: ${{ vars.ROLE_TO_ASSUME }}
44+
aws-region: ${{ vars.AWS_REGION }}
45+
46+
- name: Deploy API
47+
working-directory: ./apps/api
48+
run: pnpm sst deploy --stage ${{ inputs.sst-stage }}
49+
env:
50+
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
51+
DATABASE_URL: ${{ secrets.DATABASE_URL }}
52+
SG_CARS_TRENDS_API_TOKEN: ${{ secrets.SG_CARS_TRENDS_API_TOKEN }}
53+
UPSTASH_REDIS_REST_TOKEN: ${{ secrets.UPSTASH_REDIS_REST_TOKEN }}
54+
UPSTASH_REDIS_REST_URL: ${{ secrets.UPSTASH_REDIS_REST_URL }}
55+
FEATURE_FLAG_RATE_LIMIT: ${{ vars.FEATURE_FLAG_RATE_LIMIT }}

.github/workflows/deploy-trigger.yml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Deploy Trigger.dev
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
environment:
7+
description: "GitHub environment name"
8+
required: true
9+
type: string
10+
11+
permissions:
12+
contents: read
13+
packages: read
14+
15+
jobs:
16+
deploy-trigger:
17+
runs-on: ubuntu-latest
18+
if: startsWith(github.ref, 'refs/tags/')
19+
environment: ${{ inputs.environment }}
20+
21+
steps:
22+
- uses: actions/checkout@v4
23+
- uses: pnpm/action-setup@v4
24+
with:
25+
version: '10.4.1'
26+
- uses: actions/setup-node@v4
27+
with:
28+
node-version: '20'
29+
cache: "pnpm"
30+
31+
- name: Install dependencies
32+
run: pnpm install
33+
34+
- name: Deploy Trigger.dev
35+
working-directory: ./apps/updater
36+
run: pnpm trigger:deploy
37+
env:
38+
TRIGGER_ACCESS_TOKEN: ${{ secrets.TRIGGER_ACCESS_TOKEN }}

.github/workflows/deploy-updater.yml

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Deploy Updater
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
environment:
7+
description: "GitHub environment name"
8+
required: true
9+
type: string
10+
sst-stage:
11+
description: "SST deployment stage"
12+
required: true
13+
type: string
14+
15+
permissions:
16+
id-token: write
17+
contents: read
18+
packages: read
19+
20+
jobs:
21+
deploy-updater:
22+
runs-on: ubuntu-latest
23+
environment: ${{ inputs.environment }}
24+
# Concurrency group name ensures concurrent workflow runs wait for any in-progress job to finish
25+
concurrency:
26+
group: updater-${{ inputs.environment }}-${{ github.ref }}
27+
28+
steps:
29+
- uses: actions/checkout@v4
30+
- uses: pnpm/action-setup@v4
31+
with:
32+
version: '10.4.1'
33+
- uses: actions/setup-node@v4
34+
with:
35+
node-version: '20'
36+
cache: "pnpm"
37+
38+
- name: Install dependencies
39+
run: pnpm install
40+
41+
- uses: aws-actions/configure-aws-credentials@v4
42+
with:
43+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
44+
aws-region: ${{ vars.AWS_REGION }}
45+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
46+
47+
- name: Deploy Updater
48+
working-directory: ./apps/updater
49+
run: pnpm sst deploy --stage ${{ inputs.sst-stage }}
50+
env:
51+
UPDATER_API_TOKEN: ${{ secrets.UPDATER_API_TOKEN }}
52+
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
53+
DATABASE_URL: ${{ secrets.DATABASE_URL }}
54+
UPSTASH_REDIS_REST_URL: ${{ secrets.UPSTASH_REDIS_REST_URL }}
55+
UPSTASH_REDIS_REST_TOKEN: ${{ secrets.UPSTASH_REDIS_REST_TOKEN }}

.github/workflows/dev.yml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Deploy (Dev)
2+
3+
on:
4+
push:
5+
branches-ignore:
6+
- "main"
7+
- "release/**"
8+
9+
permissions:
10+
id-token: write
11+
contents: read
12+
packages: read
13+
14+
jobs:
15+
test:
16+
uses: ./.github/workflows/test.yml
17+
18+
run-migrations:
19+
uses: ./.github/workflows/run-migrations.yml
20+
with:
21+
environment: Development
22+
secrets: inherit
23+
24+
deploy-api:
25+
needs: [run-migrations, test]
26+
uses: ./.github/workflows/deploy-api.yml
27+
with:
28+
environment: Development
29+
sst-stage: dev
30+
secrets: inherit
31+
32+
deploy-updater:
33+
needs: [run-migrations, test]
34+
uses: ./.github/workflows/deploy-updater.yml
35+
with:
36+
environment: Development
37+
sst-stage: dev
38+
secrets: inherit

.github/workflows/prod.yml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Deploy (Production)
2+
3+
on:
4+
push:
5+
tags:
6+
- "v[0-9]+.[0-9]+.[0-9]+"
7+
- "v[0-9]+.[0-9]+.[0-9]+-beta.[0-9]+"
8+
9+
permissions:
10+
id-token: write
11+
contents: read
12+
packages: read
13+
14+
jobs:
15+
run-migrations:
16+
uses: ./.github/workflows/run-migrations.yml
17+
with:
18+
environment: Production
19+
secrets: inherit
20+
21+
deploy-api:
22+
needs: run-migrations
23+
uses: ./.github/workflows/deploy-api.yml
24+
with:
25+
environment: Production
26+
sst-stage: prod
27+
secrets: inherit
28+
29+
deploy-updater:
30+
needs: run-migrations
31+
uses: ./.github/workflows/deploy-updater.yml
32+
with:
33+
environment: Production
34+
sst-stage: prod
35+
secrets: inherit
36+
37+
deploy-trigger:
38+
needs: run-migrations
39+
uses: ./.github/workflows/deploy-trigger.yml
40+
secrets: inherit
41+
with:
42+
environment: 'Production'

.github/workflows/run-migrations.yml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Run Database Migrations
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
environment:
7+
description: "GitHub environment name"
8+
required: true
9+
type: string
10+
11+
permissions:
12+
id-token: write
13+
contents: read
14+
packages: read
15+
16+
jobs:
17+
run-migrations:
18+
runs-on: ubuntu-latest
19+
environment: ${{ inputs.environment }}
20+
# Concurrency group name ensures concurrent workflow runs wait for any in-progress job to finish
21+
concurrency:
22+
group: migrations-${{ inputs.environment }}-${{ github.ref }}
23+
24+
steps:
25+
- uses: actions/checkout@v4
26+
- uses: pnpm/action-setup@v4
27+
with:
28+
version: '10.4.1'
29+
- uses: actions/setup-node@v4
30+
with:
31+
node-version: '20'
32+
cache: "pnpm"
33+
34+
- name: Install dependencies
35+
run: pnpm install
36+
37+
- uses: aws-actions/configure-aws-credentials@v4
38+
with:
39+
role-to-assume: ${{ vars.ROLE_TO_ASSUME }}
40+
aws-region: ${{ vars.AWS_REGION }}
41+
42+
- name: Run migrations
43+
working-directory: ./packages/schema
44+
run: pnpm migrate
45+
env:
46+
DATABASE_URL: ${{ secrets.DATABASE_URL }}

.github/workflows/sst.deploy.yml

-66
This file was deleted.

.github/workflows/sst.dev.yml

-20
This file was deleted.

.github/workflows/sst.prod.yml

-20
This file was deleted.

0 commit comments

Comments
 (0)