Prompt zum Erstellen eines GitHub Actions Deploy-Workflows
KI-Agent-Prompt zum Generieren eines produktionsreifen GitHub Actions CI/CD-Workflows für eine Next.js-App mit Type-Check, Test, Build und Deploy-Schritten.
CursorClaude CodeCodexWindsurf Next.jsTypeScriptCloudflare
Geben Sie diesen Prompt Ihrem Agenten, um eine kampferprobte GitHub Actions-Workflow-Datei zu generieren, die Type-Checking, Tests und einen Production-Build vor dem Deployment ausführt – ohne Secrets zu committen oder veraltete Action-Versionen zu verwenden.
Haupt-Prompt
You are working in a Next.js 15 project that uses TypeScript and Bun as the package manager.Deployments go to Cloudflare Pages.
Task: create a GitHub Actions CI/CD workflow at `.github/workflows/deploy.yml`.
Requirements:- Trigger on: `push` to `main` and `pull_request` targeting `main`.- On pull_request: run only the `ci` job (lint, typecheck, build).- On push to main: run `ci` then `deploy` (deploy only if ci passes).- `ci` job: - Runner: `ubuntu-latest`. - Steps: checkout, setup Bun (`oven-sh/setup-bun@v2`), `bun install --frozen-lockfile`, `bun run typecheck`, `bun run build`. - Cache: use `actions/cache@v4` to cache `node_modules` keyed on `bun.lock` hash.- `deploy` job: - needs: [ci] - if: `github.event_name == 'push'` - Deploy to Cloudflare Pages using `cloudflare/wrangler-action@v3`. - Secrets used: `CLOUDFLARE_API_TOKEN` and `CLOUDFLARE_ACCOUNT_ID` (from GitHub secrets — do NOT hard-code values). - Set `command: pages deploy .next --project-name=my-app --branch=main`.- Add a concurrency group to cancel in-progress runs on the same branch.- Do NOT pin to `@v1` of any action — use the versions specified above.- Do NOT store any secret value in the YAML file.
Stop and show the complete workflow YAML before writing the file.Implementierungshinweise
oven-sh/setup-bun@v2installiert die Bun-Version aus.bun-versionoderpackage.json#engines.bunfalls vorhanden – stellen Sie sicher, dass eine dieser Dateien existiert oder legen Sie die Version mitbun-version: '1.x'fest.--frozen-lockfileverhindert, dass die CI stillschweigend Abhängigkeiten aktualisiert; ein Fehler hier bedeutet, dassbun.locklokal nicht synchron ist.- Cloudflare Pages mit
wrangler-action@v3erfordert, dass das Projekt zuerst im Cloudflare-Dashboard existiert – dokumentieren Sie diese Voraussetzung in einem Kommentar innerhalb der YAML. - Parallelität: Verwenden Sie
group: ${{ github.workflow }}-${{ github.ref }}mitcancel-in-progress: true.
Erwartete Dateiänderungen
.github/workflows/deploy.yml (new)Akzeptanzkriterien
- Ein PR zu
mainlöst nur denci-Job aus und sendet einen Status-Check. - Ein Merge zu
mainlöst nacheinanderciund danndeployaus. - Keine Secrets erscheinen in der YAML-Datei.
- Ein zweiter Push in denselben Branch bricht den vorherigen laufenden Durchlauf ab.
Testbefehle
# validate YAML syntax locallybun x @actions/validator .github/workflows/deploy.yml || true# or use actionlintdocker run --rm -v "$(pwd):/repo" rhysd/actionlint:latest /repo/.github/workflows/deploy.ymlHäufige KI-Fehler
- Hartcodierung des
CLOUDFLARE_API_TOKEN-Werts anstelle von${{ secrets.CLOUDFLARE_API_TOKEN }}. - Verwendung veralteter
actions/checkout@v2oderactions/cache@v2anstelle von v4. - Ausführen des Deploy-Jobs bei pull_request-Events, Deployment von Forks.
- Fehlendes
needs: [ci]im Deploy-Job, was Deployments auch bei Testfehlern erlaubt.
Fix-Prompt
The workflow deploys even when CI fails, or secrets are exposed. Fix in order:1. Add `needs: [ci]` to the `deploy` job.2. Add `if: github.event_name == 'push' && github.ref == 'refs/heads/main'` to the deploy job.3. Replace any hard-coded token values with `${{ secrets.CLOUDFLARE_API_TOKEN }}`.4. Upgrade any @v1/@v2 action references to the versions specified in the original prompt.Show only the corrected YAML diff.