-
I'd like to avoid duplicating long path lists. But with below,
What am I doing wrong? - uses: actions/cache/restore@v4
id: cache-restore
with:
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/package-lock.json') }}
path: |
node_modules
apps/*/node_modules
packages/lib/node_modules
packages/lib/client/node_modules
packages/lib/server/node_modules
- run: npm ci --prefer-offline
if: steps.cache-restore.outputs.cache-hit != 'true'
- uses: actions/cache/save@v4
if: steps.cache-restore.outputs.cache-hit != 'true'
with:
key: ${{ steps.cache-restore.outputs.cache-primary-key }}
path: ${{ steps.cache-restore.inputs.path }} ChatGPT claims "In GitHub Actions, steps within a job can share data using outputs, but there isn't a direct method to retrieve the value of Hallucination or true? |
Beta Was this translation helpful? Give feedback.
Answered by
lkraav
Mar 20, 2024
Replies: 2 comments
-
Going with ...
jobs:
eslint:
runs-on: ubuntu-latest
env:
# Following official recommendation to just cache `~/.npm` is a performance nightmare.
# It takes `npm ci` 3 min to complete 3000+ packages, 1.5G of data.
# Restoring compressed ~150MB `node_modules` from cache takes 10 sec.
#
# @see https://github.com/npm/cli/issues/2011
# @see https://github.com/npm/cli/issues/3208
NODE_MODULES_PATHS: |
node_modules
apps/*/node_modules
packages/lib/node_modules
packages/lib/client/node_modules
packages/lib/server/node_modules
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: 16
# @see https://github.com/actions/setup-node/issues/416
# @see https://github.com/actions/cache/blob/main/examples.md#node---npm
# @see https://github.com/actions/cache/tree/main/restore
- uses: actions/cache/restore@v4
id: cache-restore
with:
key: ${{ runner.os }}-node_modules-test-1-${{ hashFiles('**/package-lock.json') }}
path: ${{ env.NODE_MODULES_PATHS }}
- run: npm ci --prefer-offline
if: steps.cache-restore.outputs.cache-hit != 'true'
# @see https://stackoverflow.com/questions/60491837/saving-cache-on-job-failure-in-github-actions
# @see https://github.com/actions/cache/issues/92
# @see https://github.com/actions/cache/tree/main/save
- uses: actions/cache/save@v4
if: steps.cache-restore.outputs.cache-hit != 'true'
with:
key: ${{ steps.cache-restore.outputs.cache-primary-key }}
path: ${{ env.NODE_MODULES_PATHS }} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
lkraav
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Going with
jobs.<id>.env
seems to do what I want well