Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(action): fix file key hash calculation #17

Merged
merged 2 commits into from
Jun 30, 2023
Merged

Conversation

m1yon
Copy link
Contributor

@m1yon m1yon commented Jun 29, 2023

Currently, the portion of the cache key that caches files isn't matching correctly. Here you can see the last part of the key is empty (current setup):

CleanShot 2023-06-29 at 15 46 15

Changing the blob patterns to more explicit seems to match the files correctly (proposed fix):

CleanShot 2023-06-29 at 15 47 47

@m1yon m1yon requested a review from jongwooo as a code owner June 29, 2023 22:48
@jongwooo jongwooo added the bug Something isn't working label Jun 30, 2023
action.yml Outdated
@@ -10,7 +10,7 @@ runs:
path: |
${{ github.workspace }}/.next/cache
key: |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/npm-shrinkwrap.json', '**/yarn.lock', '**/pnpm-lock.yaml)') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/npm-shrinkwrap.json', '**/yarn.lock', '**/pnpm-lock.yaml)') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@m1yon Thank you for your contribution:)

@jongwooo jongwooo merged commit 8ed7862 into jongwooo:main Jun 30, 2023
2 of 3 checks passed
kodiakhq bot pushed a commit to vercel/next.js that referenced this pull request Aug 25, 2023
Hello!

I recently tried to cache the `.next/cache` directory in a GitHub action following what was said in the documentation and realized that hashing the source files didn't work properly.

This problem also occured in [next-cache](https://github.com/jongwooo/next-cache) and was fixed by [this PR](jongwooo/next-cache#17).

This PR simply changes the example from the documentation to apply the same fix (stop using brackets in the patterns passed to `hashFiles`).

Hope it helps!

### Improving Documentation

- [x] Run `pnpm prettier-fix` to fix formatting issues before opening the PR.
- [x] Read the Docs Contribution Guide to ensure your contribution follows the docs guidelines: https://nextjs.org/docs/community/contribution-guide
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants