Skip to content

Commit ebac2c5

Browse files
committed
feat(GitHubActions): Add caching for publish
1 parent 652ace4 commit ebac2c5

File tree

1 file changed

+37
-14
lines changed

1 file changed

+37
-14
lines changed

.github/workflows/publish.yml

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,48 @@ jobs:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- uses: actions/checkout@v4
15+
16+
# Reference: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#example-using-the-cache-action
17+
- name: Cache node modules
18+
id: cache-npm
19+
uses: actions/cache@v4.0.2
20+
env:
21+
cache-name: cache-node-modules
22+
with:
23+
# npm cache files are stored in `~/.npm` on Linux/macOS
24+
path: ~/.npm
25+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
26+
restore-keys: |
27+
${{ runner.os }}-build-${{ env.cache-name }}-
28+
${{ runner.os }}-build-
29+
${{ runner.os }}-
30+
31+
- if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }}
32+
name: List the state of node modules
33+
continue-on-error: true
34+
run: npm list
35+
1536
- uses: actions/setup-node@v3
1637
with:
17-
node-version: 16 # TODO: extract this to strategy.matrix, reference: https://github.com/orgs/community/discussions/26284#discussioncomment-3251198
38+
# TODO: extract this to strategy.matrix, reference: https://github.com/orgs/community/discussions/26284#discussioncomment-3251198
39+
node-version: 16
40+
1841
- run: npm ci
1942
- run: npm test
2043

21-
# publish-npm:
22-
# needs: build
23-
# runs-on: ubuntu-latest
24-
# steps:
25-
# - uses: actions/checkout@v4
26-
# - uses: actions/setup-node@v3
27-
# with:
28-
# node-version: 16
29-
# registry-url: https://registry.npmjs.org/
30-
# - run: npm ci
31-
# - run: npm publish
32-
# env:
33-
# NODE_AUTH_TOKEN: ${{secrets.npm_token}}
44+
# publish-npm:
45+
# needs: build
46+
# runs-on: ubuntu-latest
47+
# steps:
48+
# - uses: actions/checkout@v4
49+
# - uses: actions/setup-node@v3
50+
# with:
51+
# node-version: 16
52+
# registry-url: https://registry.npmjs.org/
53+
# - run: npm ci
54+
# - run: npm publish
55+
# env:
56+
# NODE_AUTH_TOKEN: ${{secrets.npm_token}}
3457

3558
publish-gpr:
3659
needs: build

0 commit comments

Comments
 (0)