04 · CI/CD Pipeline
The workflows
Section titled “The workflows”Each repo got two files:
.github/workflows/ci.yml — quality gate (PRs + pushes to main):
name: CIon: pull_request: push: branches: [main]jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: { node-version: 22, cache: npm } - run: npm ci - run: npm run build.github/workflows/deploy.yml — CD on push to main (final version):
name: Deployon: push: branches: [main]jobs: deploy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: { node-version: 22, cache: npm } - run: npm ci - run: npm run build - name: Create Cloudflare Pages project run: npx -y wrangler@4 pages project create sambasene-public-docs --production-branch=main || echo "project already exists" env: CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} - name: Deploy to Cloudflare Pages uses: cloudflare/wrangler-action@v3 with: apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} wranglerVersion: "4.30.0" command: pages deploy dist --project-name=sambasene-public-docs --commit-dirty=trueRequired secrets (both repos): CLOUDFLARE_API_TOKEN (Cloudflare Pages: Edit) and CLOUDFLARE_ACCOUNT_ID.
Failure #1 — “Project not found” (code 8000007)
Section titled “Failure #1 — “Project not found” (code 8000007)”First deploy run:
✘ ERROR A request to the Cloudflare API (/accounts/***/pages/projects/public-docs) failed. Project not found. The specified project name does not match any of your existing projects. [code: 8000007]Cause: modern wrangler (4.x) no longer auto-creates Pages projects; pages deploy requires the project to exist. (The token was fine — auth’d error, so the secrets were correctly scoped.)
Fix attempt: added pages project create … || true inside the wrangler-action command:.
Failure #2 — “Unknown arguments: ||, true”
Section titled “Failure #2 — “Unknown arguments: ||, true””✘ ERROR Unknown arguments: ||, trueCause: wrangler-action passes each command line straight to wrangler — no shell involved, so shell operators fail.
Fix: move project creation into a real shell run: step (where || is legitimate) with npx -y wrangler@4, and pin wranglerVersion in the action so both repos behave identically (public-docs’ local wrangler is 4.30; without pinning, private-docs got the action’s own 3.90).
Reasoning
Section titled “Reasoning”The second failure is the classic “shell syntax in a non-shell runner” trap. The lesson: GHA run: blocks are shells; action inputs are not. Pinning versions across repos prevents “works here, different wrangler there” drift.
Result
Section titled “Result”| Run | CI | Deploy |
|---|---|---|
| After branch rename (no secrets yet) | ✅ | — (skipped/failed expected) |
| Trigger commit (secrets in) | ✅ | ❌ failure #1 |
| Create-step added | ✅ | ❌ failure #2 |
| Shell step + pinned wrangler | ✅ | ✅ green |
Both repos: CI green, Deploy green. Projects created, first content live.