Monorepo Build #20
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
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: Build UI | |
run: | | |
cd apps/ui | |
bun install | |
bun next build | |
build-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 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: oven-sh/setup-bun@v1 | |
with: | |
bun-version: latest | |
- name: Build API | |
run: | | |
cd apps/api | |
bun install | |
bun run build |