Cache configuration issue in GitHub Actions workflow.
The issue involves a GitHub Actions workflow where the Next.js build cache is not being detected despite proper configuration. The problem seems related to cache setup or potential directory clearing before the build. The solution requires understanding GitHub Actions caching and Next.js build processes.
https://github.com/RebootGG/va-frontend
I'm building and deploying the app via Github actions, on an instance.
Here is my .github/workflow.yml file :
name: Deploy to Server
on:
push:
branches:
- master
jobs:
deploy:
runs-on: self-hosted
steps:
- name: Cache Node.js modules
uses: actions/cache@v3
with:
path: |
~/.npm
${{ github.workspace }}/.next/cache
# Generate a new cache whenever packages or source files change.
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
# If source files changed but packages didn't, rebuild from a prior cache.
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-
- name: Checkout
uses: actions/checkout@v4
with:
ssh-key: ${{ secrets.SSH_KEY }}
- name: Execute Deployment Commands
run: |
git pull origin master
npm install
npm run build
pm2 restart all
Even though i'm using the instructions from the docs, I still get the following message during the "npm run build" command:
> build
> next build
⚠ No build cache found. Please configure build caching for faster rebuilds. Read more: https://nextjs.org/docs/messages/no-cache
I would expect Next.js to retrieve the cache from the previous builds.
Operating System:
Platform: linux
Arch: x64
Version: #99-Ubuntu SMP Mon Oct 3
Claim this issue to let others know you're working on it. You'll earn 20 points when you complete it!