{
  "id": "create-a-github-actions-deploy-workflow",
  "type": "prompts",
  "category": "prompts",
  "locale": "fr",
  "url": "/fr/prompts/create-a-github-actions-deploy-workflow",
  "title": "Prompt pour créer un workflow de déploiement GitHub Actions",
  "description": "Prompt d'agent IA pour générer un workflow CI/CD GitHub Actions de production pour une application Next.js avec les étapes de vérification de type, test, build et déploiement.",
  "tools": [
    "Cursor",
    "Claude Code",
    "Codex",
    "Windsurf"
  ],
  "stack": [
    "Next.js",
    "TypeScript",
    "Cloudflare"
  ],
  "tags": [
    "deploy",
    "nextjs",
    "typescript",
    "cloudflare"
  ],
  "difficulty": "medium",
  "updated": "2026-06-08",
  "markdown": "Donnez ce prompt à votre agent pour générer un fichier de workflow GitHub Actions éprouvé\nqui exécute la vérification de type, les tests et un build de production avant le déploiement — sans\ncommettre de secrets ni utiliser de versions d'actions dépréciées.\n\n## Prompt Principal\n\n```txt title=\"Main Prompt\"\nYou are working in a Next.js 15 project that uses TypeScript and Bun as the package manager.\nDeployments go to Cloudflare Pages.\n\nTask: create a GitHub Actions CI/CD workflow at `.github/workflows/deploy.yml`.\n\nRequirements:\n- Trigger on: `push` to `main` and `pull_request` targeting `main`.\n- On pull_request: run only the `ci` job (lint, typecheck, build).\n- On push to main: run `ci` then `deploy` (deploy only if ci passes).\n- `ci` job:\n  - Runner: `ubuntu-latest`.\n  - Steps: checkout, setup Bun (`oven-sh/setup-bun@v2`), `bun install --frozen-lockfile`,\n    `bun run typecheck`, `bun run build`.\n  - Cache: use `actions/cache@v4` to cache `node_modules` keyed on `bun.lock` hash.\n- `deploy` job:\n  - needs: [ci]\n  - if: `github.event_name == 'push'`\n  - Deploy to Cloudflare Pages using `cloudflare/wrangler-action@v3`.\n  - Secrets used: `CLOUDFLARE_API_TOKEN` and `CLOUDFLARE_ACCOUNT_ID` (from GitHub secrets — do NOT\n    hard-code values).\n  - Set `command: pages deploy .next --project-name=my-app --branch=main`.\n- Add a concurrency group to cancel in-progress runs on the same branch.\n- Do NOT pin to `@v1` of any action — use the versions specified above.\n- Do NOT store any secret value in the YAML file.\n\nStop and show the complete workflow YAML before writing the file.\n```\n\n## Notes d'Implémentation\n\n- `oven-sh/setup-bun@v2` installe la version de Bun depuis `.bun-version` ou `package.json#engines.bun`\n  si présent — assurez-vous que l'un de ces fichiers existe ou spécifiez avec `bun-version: '1.x'`.\n- `--frozen-lockfile` empêche le CI de mettre à jour silencieusement les dépendances ; un échec ici signifie que `bun.lock`\n  est désynchronisé localement.\n- Cloudflare Pages avec `wrangler-action@v3` nécessite que le projet existe dans le tableau de bord Cloudflare\n  en premier lieu — documentez cette condition préalable dans un commentaire à l'intérieur du YAML.\n- Concurrence : utilisez `group: ${{ github.workflow }}-${{ github.ref }}` avec `cancel-in-progress: true`.\n\n## Changements de Fichiers Attendus\n\n```txt\n.github/workflows/deploy.yml    (new)\n```\n\n## Critères d'Acceptation\n\n- Une PR vers `main` déclenche uniquement le job `ci` et publie un statut de vérification.\n- La fusion vers `main` déclenche `ci` puis `deploy`, dans cet ordre.\n- Aucun secret n'apparaît dans le fichier YAML.\n- Un deuxième push sur la même branche annule la précédente exécution en cours.\n\n## Commandes de Test\n\n```bash\n# validate YAML syntax locally\nbun x @actions/validator .github/workflows/deploy.yml || true\n# or use actionlint\ndocker run --rm -v \"$(pwd):/repo\" rhysd/actionlint:latest /repo/.github/workflows/deploy.yml\n```\n\n## Erreurs Courantes des IA\n\n- Coder en dur la valeur de `CLOUDFLARE_API_TOKEN` au lieu d'utiliser `${{ secrets.CLOUDFLARE_API_TOKEN }}`.\n- Utiliser des versions dépréciées `actions/checkout@v2` ou `actions/cache@v2` au lieu de v4.\n- Exécuter le job de déploiement sur des événements pull_request, ce qui déploie depuis des forks.\n- Oublier `needs: [ci]` sur le job de déploiement, permettant des déploiements même si les tests échouent.\n\n## Prompt de Correction\n\n```txt title=\"Fix Prompt\"\nThe workflow deploys even when CI fails, or secrets are exposed. Fix in order:\n1. Add `needs: [ci]` to the `deploy` job.\n2. Add `if: github.event_name == 'push' && github.ref == 'refs/heads/main'` to the deploy job.\n3. Replace any hard-coded token values with `${{ secrets.CLOUDFLARE_API_TOKEN }}`.\n4. Upgrade any @v1/@v2 action references to the versions specified in the original prompt.\nShow only the corrected YAML diff.\n```"
}