From 9b633bd8e0dcae3cc365926628c5b327f8f4801b Mon Sep 17 00:00:00 2001 From: codex-bot Date: Mon, 20 Oct 2025 17:58:36 -0300 Subject: [PATCH] CI: habilitar cache do Next.js (.next/cache) em GitHub Actions (quality-checks e deploy self-hosted) e preservar cache entre builds --- .github/workflows/ci-cd-web-desktop.yml | 16 ++++++++++------ .github/workflows/quality-checks.yml | 9 +++++++++ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci-cd-web-desktop.yml b/.github/workflows/ci-cd-web-desktop.yml index 6b8de09..6351f88 100644 --- a/.github/workflows/ci-cd-web-desktop.yml +++ b/.github/workflows/ci-cd-web-desktop.yml @@ -169,16 +169,20 @@ jobs: # Remove desktop app to avoid pnpm touching its node_modules on this runner rm -rf apps/desktop || true - - name: Clean Next.js cache (.next) to avoid EACCES + - name: Ensure Next.js cache directory exists and is writable run: | cd "$EFFECTIVE_APP_DIR" - if [ -e .next ]; then - echo "Removing existing .next (may be root-owned from previous container)" - rm -rf .next || (mv .next ".next.old.$(date +%s)" || true) - fi - mkdir -p .next + mkdir -p .next/cache chmod -R u+rwX .next || true + - name: Cache Next.js build cache (.next/cache) + uses: actions/cache@v4 + with: + path: ${{ env.EFFECTIVE_APP_DIR }}/.next/cache + key: ${{ runner.os }}-nextjs-${{ hashFiles('pnpm-lock.yaml') }}-${{ hashFiles('src/**/*.ts', 'src/**/*.tsx', 'src/**/*.js', 'src/**/*.jsx', 'next.config.ts') }} + restore-keys: | + ${{ runner.os }}-nextjs-${{ hashFiles('pnpm-lock.yaml') }}- + - name: Install and build (Next.js) run: | cd "$EFFECTIVE_APP_DIR" diff --git a/.github/workflows/quality-checks.yml b/.github/workflows/quality-checks.yml index 4f72d06..4fa4f33 100644 --- a/.github/workflows/quality-checks.yml +++ b/.github/workflows/quality-checks.yml @@ -36,6 +36,15 @@ jobs: - name: Install dependencies run: pnpm install --frozen-lockfile + - name: Cache Next.js build cache + uses: actions/cache@v4 + with: + path: | + ${{ github.workspace }}/.next/cache + key: ${{ runner.os }}-nextjs-${{ hashFiles('pnpm-lock.yaml') }}-${{ hashFiles('**/*.{js,jsx,ts,tsx}') }} + restore-keys: | + ${{ runner.os }}-nextjs-${{ hashFiles('pnpm-lock.yaml') }}- + - name: Generate Prisma client run: pnpm prisma:generate