This repository has been archived by the owner on May 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
98 lines (93 loc) · 3.62 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
name: 🔨 build
on:
workflow_call:
outputs:
publish:
description: "Indicates if the project should be published to NPM"
value: ${{ jobs.prepublish.outputs.publish }}
jobs:
prepublish:
name: check version
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }} - ${{ matrix.package }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}
cancel-in-progress: true
outputs:
publish: ${{ steps.do-publish.outputs.publish }}
steps:
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 16.x
- name: Get Version
id: get-version
run: echo "PACKAGE_VERSION=$(node .github/scripts/github/get-version)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
id: prepublished
with:
key: cache-prepublish-${{ steps.get-version.outputs.PACKAGE_VERSION }}
path: |
.prepublish-cache
- name: Check Publish
id: do-publish
run: echo "publish=${{steps.prepublished.outputs.cache-hit != 'true'}}" >> $GITHUB_OUTPUT
- name: Copy Package.json to cache
if: steps.prepublished.outputs.cache-hit != 'true'
run: |
mkdir -p .prepublish-cache
cp package.json .prepublish-cache/package.json
build:
name: ${{ matrix.package }}
runs-on: ubuntu-latest
strategy:
matrix:
package: [server, staff, web, ui]
concurrency:
group: ${{ github.workflow }} - ${{ matrix.package }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}
cancel-in-progress: true
outputs:
publish: ${{ steps.do-publish.outputs.publish }}
steps:
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Calculating Hash
run: |
echo "TURBO_VERSION=$( npm show turbo version )" >> $GITHUB_ENV
echo "NPM_GLOBAL_MODULES=$( npm root -g )" >> $GITHUB_ENV
echo "TURBO_HASH=$( npx --yes turbo run build --dry --only --filter=@kenthackenough/${{ matrix.package }} | grep = | grep Hash | tail -1 | cut -f2- -d= | xargs )" >> $GITHUB_ENV
- uses: actions/cache@v3
name: Cache - Turbo
id: turbo-cache
with:
path: |
.turbo
${{ github.workspace }}/projects/*/.next/cache
key: cache-turbo-build-${{ matrix.package }}-${{ hashFiles('package-lock.json') }}-${{ env.TURBO_HASH }}
restore-keys: |
cache-turbo-build-${{ matrix.package }}-${{ hashFiles('package-lock.json') }}-
- name: Validate Hash
run: |
echo "FULL_TURBO=$( $(find .turbo -iname "${{ env.TURBO_HASH }}-*" | grep ${{ env.TURBO_HASH }}) && echo 'yes' || echo 'no' )" >> $GITHUB_ENV
- uses: actions/cache@v3
name: Cache - NPM
id: npm-cache
with:
path: |
~/.npm
${{ github.workspace }}/node_modules
${{ github.workspace }}/package.json
${{ github.workspace }}/github/scripts/*/node_modules
${{ github.workspace }}/*/*/node_modules
${{ github.workspace }}/*/*/dist
key: cache-npm-${{ hashFiles('package-lock.json') }}
restore-keys: |
cache-npm-
- name: Installing Dependencies
if: ${{ env.FULL_TURBO == 'no' }}
run: npm install --no-audit --no-fund && git restore package-lock.json
- name: Building
run: npm run build -- --cache-dir=.turbo --filter=@kenthackenough/${{ matrix.package }}...