Skip to content

Commit 37db9a4

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

File tree

2 files changed

+32
-5
lines changed

2 files changed

+32
-5
lines changed

Diff for: .github/workflows/branch.yml

+25-4
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,33 @@ jobs:
1515
id: cacheModules
1616
uses: actions/cache@v4
1717
with:
18-
path: ~/.npm # this is cache where npm installs from before going out to the network
18+
path: ~/.npm # this is the cache where npm installs from before going out to the network
1919
key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }}
2020
- name: Install dependencies
2121
if: steps.cacheModules.outputs.cache-hit != 'true'
2222
run: npm install
2323

24+
build:
25+
name: Build
26+
needs: [install]
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@v4
30+
- name: Restore node_modules
31+
uses: actions/cache@v4
32+
with:
33+
path: ~/.npm # this is the cache where npm installs from before going out to the network
34+
key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }}
35+
- name: Cache dist
36+
id: cacheDist
37+
uses: actions/cache@v4
38+
with:
39+
path: ./dist
40+
key: ${{ runner.os }}-node-${{ hashFiles('package.json', 'rollup.config.js', 'src/*.js') }}
41+
- name: Build cross-fetch
42+
if: steps.cacheDist.outputs.cache-hit != 'true'
43+
run: make dist
44+
2445
debug:
2546
name: Debug
2647
runs-on: ubuntu-latest
@@ -29,7 +50,7 @@ jobs:
2950

3051
checks:
3152
name: Check
32-
needs: [install]
53+
needs: [build]
3354
uses: ./.github/workflows/checks.yml
3455
with:
3556
ref: ${{ github.sha }}
@@ -38,13 +59,13 @@ jobs:
3859
# Github doesn't pass down the SNYK_TOKEN environment variable.
3960
security:
4061
name: Check Security
41-
needs: [install]
62+
needs: [build]
4263
runs-on: ubuntu-latest
4364
steps:
4465
- uses: actions/checkout@v4
4566
- uses: actions/cache@v4
4667
with:
47-
path: ~/.npm # this is cache where npm installs from before going out to the network
68+
path: ~/.npm # this is the cache where npm installs from before going out to the network
4869
key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }}
4970
- run: npm install --prefer-offline
5071
- run: make secure

Diff for: .github/workflows/checks.yml

+7-1
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)