Repository navigation
84 lines (70 loc) · 2.39 KB
/
Copy pathfrontend-ci.yml
File metadata and controls
84 lines (70 loc) · 2.39 KB
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
name: Frontend CI
on:
pull_request:
branches: [main, develop]
merge_group:
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
# frontend-ci is a required check: workflow-level `paths:` leaves it pending forever, a skipped job passes.
changes:
name: changes
runs-on: ubuntu-latest
outputs:
frontend: ${{ steps.filter.outputs.frontend }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Detect frontend changes
id: filter
env:
BASE_SHA: ${{ github.event.pull_request.base.sha || github.event.merge_group.base_sha }}
run: |
if [ -z "$BASE_SHA" ] || ! git cat-file -e "$BASE_SHA^{commit}" 2>/dev/null; then
echo "frontend=true" >> "$GITHUB_OUTPUT"
exit 0
fi
changed=$(git diff --name-only "$BASE_SHA" HEAD | grep -E \
'^(apps/frontend/|shared/|\.github/actions/build-shared-packages/|\.github/workflows/frontend-ci\.yml$)' || true)
if [ -n "$changed" ]; then
echo "frontend=true" >> "$GITHUB_OUTPUT"
echo "$changed" | sed 's/^/changed: /'
else
echo "frontend=false" >> "$GITHUB_OUTPUT"
echo "No frontend-relevant changes."
fi
frontend-ci:
name: frontend-ci
needs: changes
if: needs.changes.outputs.frontend == 'true'
runs-on: ubuntu-latest
defaults:
run:
working-directory: apps/frontend
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
# apps/frontend consumes @branch/rbac as a file: dependency and its dist
# is gitignored, so it has to be built before npm ci resolves it. The
# job's defaults.run working-directory does not reach a composite
# action's steps, so this still runs from the repo root as it needs to.
- name: Build shared packages
uses: ./.github/actions/build-shared-packages
- name: Install dependencies
run: npm ci
- name: TypeScript check
run: npm run typecheck
- name: Lint
run: npm run lint
- name: Build
run: npm run build
- name: Run tests
run: npm run test