Skip to content

ci(cleanup): read the Cloudflare token from the org-level CLOUDFLARE_API_TOKEN - #1111

Merged
Ardnived merged 1 commit into
mainfrom
ci/cleanup-org-cloudflare-token
Nov 11, 2026
Merged

Ardnived merged 1 commit into
mainfrom
ci/cleanup-org-cloudflare-token

Conversation

@Ardnived

Copy link
Copy Markdown
Contributor

Summary

The nightly preview-asset cleanup read its token from the repo-level CLOUDFLARE_API_KEY secret, while CLOUDFLARE_ACCOUNT_ID already came from the org. It now reads the org-level CLOUDFLARE_API_TOKEN, the same secret SahajAtlasWeb's Smoke lane publishes with, so one rotation updates both repos.

  • .github/workflows/cleanup-preview-assets.yml: CLOUDFLARE_API_KEY: ${{ secrets.CLOUDFLARE_API_TOKEN }}. The script and Railway keep the CLOUDFLARE_API_KEY name, so no app code or Railway variable changes.
  • docs/rules/storage.md: the config table lists both values as org secrets. ⚠ It now records that the token is shared: a rotation must update the org secret, and a re-scope must keep Images (Edit), Stream (Edit), and R2 Object Read & Write for this repo and Workers Scripts (Edit) for SahajAtlasWeb.

Verification

Dry-run dispatch on this branch at d9adf4e1 (apply=false, deletes nothing): run 43065427738 succeeded. All three backends authenticated with the org token, including R2's S3 credentials, which are derived from the token. The scan counts match this morning's scheduled run on the old secret:

Backend Scanned
Cloudflare Images 1193
Cloudflare Stream 134
R2 282

After merge

  • Delete the repo-level CLOUDFLARE_API_KEY Actions secret. Nothing reads it any more.

Related: sydevs/SahajAtlasWeb#386

🤖 Generated with Claude Code

…API_TOKEN

The nightly preview-asset cleanup read the repo-level `CLOUDFLARE_API_KEY`
secret while `CLOUDFLARE_ACCOUNT_ID` already came from the org. It now reads
the org-level `CLOUDFLARE_API_TOKEN` that SahajAtlasWeb's Smoke lane uses, so
one rotation updates both repos. The script and Railway keep the
`CLOUDFLARE_API_KEY` name, so only the workflow's mapping changes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@railway-app

railway-app Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

🚅 Deployed to the SahajCloud-pr-1111 environment in sahajcloud

Service Status Web Updated
SahajCloud ✅ Success (View Logs) Web Nov 11, 2026 at 5:14 pm UTC
1 service not affected by this PR
  • mailpit

@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-1111 November 11, 2026 17:11 Destroyed
@Ardnived
Ardnived merged commit fef565a into main Nov 11, 2026
9 of 10 checks passed
@Ardnived
Ardnived deleted the ci/cleanup-org-cloudflare-token branch November 11, 2026 17:16
@sydevs-bot sydevs-bot moved this from Awaiting to Done in SYDevelopers Technical Roadmap Nov 11, 2026
sydevs-bot pushed a commit that referenced this pull request Nov 11, 2026
`Register the preview's fixed address` failed on this PR's own head:

    CloudflareError: Cloudflare PUT /accounts/***/storage/kv/namespaces/
    9c43446be07544ae933284c8967b5d20/values/pr-1082: HTTP 401 — 10000:
    Authentication error

The step read `secrets.CLOUDFLARE_API_KEY`, which is the name of the
environment variable the scripts and Railway use, not the name of the
GitHub secret holding the account's API token. #1111 moved the nightly
cleanup off that repo-level secret and onto the org-level
`CLOUDFLARE_API_TOKEN` for the same reason; both steps added here were
written before it and kept the old name.

The sweep step shadowed the job's Cloudflare pair with its own copy, so
merging #1111 left one file handing `scripts/preview-domain.ts` two
different credentials depending on which step invoked it. The copy is
deleted rather than corrected — it is the drift that the job-level
values exist to prevent.

This fixes which token is sent. Whether that token carries Workers KV
Storage:Edit, Workers Scripts:Edit, Zone:Read and the zone's Workers
Routes:Edit is still step 0's, and the check stays red until it does.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjWoSjeryJXkLhfAYYL

This branch was successfully deployed

No deployments
sahajcloud / SahajCloud-pr-1111 — d9adf4e1 Deployed Nov 11, 2026 by railway-app[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

1 participant