Skip to content

Commit

Permalink
ci: save cache if default branch
Browse files Browse the repository at this point in the history
  • Loading branch information
sasaplus1 committed Nov 15, 2024
1 parent c323007 commit 388f3cd
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,16 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
registry-url: 'https://registry.npmjs.org'
- id: npm-cache
run: echo "dir=$(npm config get cache)" | tee -a "$GITHUB_OUTPUT"
- id: npm-cache-restore
uses: actions/cache/restore@v4
with:
path: ${{ steps.npm-cache.outputs.dir }}
key: npm-${{ hashFiles('package-lock.json') }}
restore-keys: |
npm-
- name: Set git user
run: |
git config --global user.name 'github-actions[bot]'
Expand Down
16 changes: 15 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,28 @@ jobs:
node:
- 18
- 20
- 22
- lts/*
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
cache: npm
node-version: ${{ matrix.node }}
- id: npm-cache
run: echo "dir=$(npm config get cache)" | tee -a "$GITHUB_OUTPUT"
- id: npm-cache-restore
uses: actions/cache/restore@v4
with:
path: ${{ steps.npm-cache.outputs.dir }}
key: npm-${{ hashFiles('package-lock.json') }}
restore-keys: |
npm-
- run: npm ci
- run: npm test
- uses: actions/cache/save@v4
if: github.ref_name == 'main'
with:
path: ${{ steps.npm-cache.outputs.dir }}
key: ${{ steps.npm-cache-restore.outputs.cache-primary-key }}

0 comments on commit 388f3cd

Please sign in to comment.