Aller au contenu principal

Template — Frontend CI

StatutActif — v1.0 — 2026-06-27
UsageCopier dans .github/workflows/frontend-ci.yml
Voir aussiPlaybook CI · Standards

Usage

Copier ce fichier dans .github/workflows/frontend-ci.yml du projet Next.js.

Les scripts lint et typecheck sont détectés automatiquement depuis package.json — ils sont simplement ignorés s'ils n'existent pas (sans faire échouer la CI).

Template

name: Frontend CI

# Standard DMV — Next.js projects
# Triggers on every PR and push to main.
# Steps: install → lint → typecheck → build
# lint and typecheck are skipped if not defined in package.json.

on:
pull_request:
push:
branches:
- main

permissions:
contents: read

jobs:
frontend:
name: Lint · Typecheck · Build
runs-on: ubuntu-latest
timeout-minutes: 20
env:
CI: true
NEXT_TELEMETRY_DISABLED: 1

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm

- name: Detect optional scripts
id: scripts
run: |
node -e "
const scripts = require('./package.json').scripts || {};
const fs = require('node:fs');
fs.appendFileSync(process.env.GITHUB_OUTPUT, \`has_lint=\${Boolean(scripts.lint)}\n\`);
fs.appendFileSync(process.env.GITHUB_OUTPUT, \`has_typecheck=\${Boolean(scripts.typecheck)}\n\`);
"

- name: Install dependencies
run: npm ci

- name: Lint
if: steps.scripts.outputs.has_lint == 'true'
run: npm run lint

- name: Typecheck
if: steps.scripts.outputs.has_typecheck == 'true'
run: npm run typecheck

- name: Build
run: npm run build
# Add project-specific NEXT_PUBLIC_* vars needed at build time here.
# Non-sensitive values should be hardcoded in next.config.ts instead
# (Cloudflare Pages does not propagate env vars to the build step).
# env:
# NEXT_PUBLIC_API_URL: ${{ secrets.NEXT_PUBLIC_API_URL }}

Status check GitHub

Activer dans Branch Protection → Required status checks :

frontend / Lint · Typecheck · Build