name: Next.js CI on: push: branches: [main, master] pull_request: branches: [main, master] jobs: lint-and-test: name: Lint and Test runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: '20' cache: 'npm' - name: Install dependencies run: npm ci - name: Run ESLint run: npm run lint - name: Run tests run: npm test -- --coverage - name: Upload coverage uses: codecov/codecov-action@v3 if: always() build: name: Build runs-on: ubuntu-latest needs: lint-and-test steps: - uses: actions/checkout@v4 - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: '20' cache: 'npm' - name: Install dependencies run: npm ci - name: Cache Next.js build uses: actions/cache@v3 with: path: | ~/.npm ${{ github.workspace }}/.next/cache key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }} restore-keys: | ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}- - name: Build Next.js application run: npm run build env: NEXT_TELEMETRY_DISABLED: 1 - name: Upload build artifacts uses: actions/upload-artifact@v3 with: name: nextjs-build path: .next retention-days: 7