-
Notifications
You must be signed in to change notification settings - Fork 0
102 lines (97 loc) · 2.86 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
name: Monorepo Build
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
inputs:
build_target:
description: "Choose what to build"
required: true
default: "both"
type: choice
options:
- ui
- api
- both
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
detect-changes:
runs-on: ubuntu-latest
outputs:
ui_changed: ${{ steps.changes.outputs.ui }}
api_changed: ${{ steps.changes.outputs.api }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v2
if: github.event_name == 'pull_request' || github.event_name == 'push'
id: changes
with:
filters: |
ui:
- 'apps/ui/**'
api:
- 'apps/api/**'
before: ${{ github.event.before }}
build-ui:
needs: detect-changes
if: >
github.event_name == 'workflow_dispatch' && (github.event.inputs.build_target == 'ui' || github.event.inputs.build_target == 'both') ||
(github.event_name != 'workflow_dispatch' && needs.detect-changes.outputs.ui_changed == 'true')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Cache Bun dependencies
uses: actions/cache@v3
with:
path: ~/.bun/install/cache
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }}
restore-keys: |
${{ runner.os }}-bun-
- name: Cache Next.js build
uses: actions/cache@v3
with:
path: apps/ui/.next/cache
key: ${{ runner.os }}-nextjs-${{ hashFiles('apps/ui/**/*.[jt]s', 'apps/ui/**/*.[jt]sx') }}
restore-keys: |
${{ runner.os }}-nextjs-
- name: Build UI
run: |
cd apps/ui
bun install
bun next build
- name: Test UI
run: |
cd apps/ui
bun test
test-api:
needs: detect-changes
if: >
github.event_name == 'workflow_dispatch' && (github.event.inputs.build_target == 'api' || github.event.inputs.build_target == 'both') ||
(github.event_name != 'workflow_dispatch' && needs.detect-changes.outputs.api_changed == 'true')
runs-on: ubuntu-latest
env:
DB_URL: ${{ secrets.DB_URL }}
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Cache Bun dependencies
uses: actions/cache@v3
with:
path: ~/.bun/install/cache
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }}
restore-keys: |
${{ runner.os }}-bun-
- name: Build API
run: |
cd apps/api
bun install
bun test