Skip to content

Commit ccf5f71

Browse files
committed
refactor: cached dist files on Github Actions
1 parent 5518a17 commit ccf5f71

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

.github/workflows/branch.yml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,24 @@ jobs:
1818
path: ~/.npm # this is cache where npm installs from before going out to the network
1919
key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }}
2020
- name: Install dependencies
21-
if: steps.cacheModules.outputs.cache-hit != 'true'
22-
run: npm install
21+
if: steps.cacheDist.outputs.cache-hit != 'true'
22+
run: make dist
23+
24+
build:
25+
name: Build
26+
needs: [install]
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@v4
30+
- name: Cache dist
31+
id: cacheDist
32+
uses: actions/cache@v4
33+
with:
34+
path: ./dist
35+
key: ${{ runner.os }}-node-${{ hashFiles('package.json', 'rollup.config.js', 'src/*.js') }}
36+
- name: Install dependencies
37+
if: steps.cacheDist.outputs.cache-hit != 'true'
38+
run: make dist
2339

2440
debug:
2541
name: Debug
@@ -29,7 +45,7 @@ jobs:
2945

3046
checks:
3147
name: Check
32-
needs: [install]
48+
needs: [build]
3349
uses: ./.github/workflows/checks.yml
3450
with:
3551
ref: ${{ github.sha }}
@@ -38,7 +54,7 @@ jobs:
3854
# Github doesn't pass down the SNYK_TOKEN environment variable.
3955
security:
4056
name: Check Security
41-
needs: [install]
57+
needs: [build]
4258
runs-on: ubuntu-latest
4359
steps:
4460
- uses: actions/checkout@v4

.github/workflows/checks.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,16 @@ jobs:
2222
- uses: actions/checkout@v4
2323
with:
2424
ref: ${{ inputs.ref }}
25-
- uses: actions/cache@v4
25+
- name: Restore node modules
26+
uses: actions/cache@v4
2627
with:
2728
path: ~/.npm # this is cache where npm installs from before going out to the network
2829
key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }}
30+
- name: Restore dist
31+
uses: actions/cache@v4
32+
with:
33+
path: ./dist
34+
key: ${{ runner.os }}-node-${{ hashFiles('package.json', 'rollup.config.js', 'src/*.js') }}
2935
- name: Use Node.js ${{ matrix.node-version }}
3036
uses: actions/setup-node@v4
3137
with:

0 commit comments

Comments
 (0)