Skip to content

Commit df2d129

Browse files
fengmk2codex
andcommitted
ci(remote-cache): guard temporary deployment button URLs
Co-authored-by: GPT-6 Codex <codex@openai.com>
1 parent e835e65 commit df2d129

4 files changed

Lines changed: 35 additions & 5 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ permissions:
77
on:
88
workflow_dispatch:
99
pull_request:
10-
types: [opened, synchronize]
10+
types: [opened, synchronize, ready_for_review, converted_to_draft]
1111
push:
1212
branches:
1313
- main
@@ -23,6 +23,35 @@ defaults:
2323
shell: bash
2424

2525
jobs:
26+
deploy-button-links:
27+
name: Deploy button links
28+
runs-on: namespace-profile-linux-x64-default
29+
steps:
30+
- uses: taiki-e/checkout-action@7d1e50e93dc4fb3bba58f85018fadf77898aee8b # v1.4.2
31+
- uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
32+
with:
33+
script: |
34+
const { readFile } = require('node:fs/promises');
35+
const main = 'https://github.com/voidzero-dev/vite-task/tree/main/packages/remote-cache';
36+
const pr = context.payload.pull_request;
37+
const temporary = pr?.draft
38+
? `https://github.com/${pr.head.repo.full_name}/tree/${pr.head.ref}/packages/remote-cache`
39+
: undefined;
40+
for (const file of ['README.md', 'packages/remote-cache/README.md', 'packages/remote-cache/docs/self-hosting.md']) {
41+
const content = await readFile(file, 'utf8');
42+
const buttons = [...content.matchAll(/\]\((https:\/\/deploy\.workers\.cloudflare\.com\/\?url=[^)]+)\)/g)];
43+
if (!buttons.length) core.setFailed(`${file}: Deploy to Cloudflare button is missing.`);
44+
for (const [, button] of buttons) {
45+
const source = new URL(button).searchParams.get('url');
46+
if (source === main) continue;
47+
if (temporary && source === temporary) {
48+
core.warning(`${file}: Temporary PR branch URL. Restore the button to main before marking this PR ready for review.`);
49+
} else {
50+
core.setFailed(`${file}: Restore the Deploy to Cloudflare source URL to ${main} before merge.`);
51+
}
52+
}
53+
}
54+
2655
detect-changes:
2756
runs-on: namespace-profile-linux-x64-default
2857
permissions:
@@ -396,6 +425,7 @@ jobs:
396425
runs-on: namespace-profile-linux-x64-default
397426
if: always()
398427
needs:
428+
- deploy-button-links
399429
- clippy
400430
- test
401431
- test-musl

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ vp run --cache build # run with caching enabled
1515

1616
## Remote cache service
1717

18-
[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https%3A%2F%2Fgithub.com%2Fvoidzero-dev%2Fvite-task%2Ftree%2Fmain%2Fpackages%2Fremote-cache)
18+
[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https%3A%2F%2Fgithub.com%2Fvoidzero-dev%2Fvite-task%2Ftree%2Ffeat%2Fpublic-remote-cache%2Fpackages%2Fremote-cache)
1919

2020
To deploy the public remote cache service in your own Cloudflare account and bind it to a GitHub repository, follow the [self-hosting guide](packages/remote-cache/docs/self-hosting.md). The service is available in this source tree; the `vp run` remote-cache client adapter is not yet implemented here.
2121

‎packages/remote-cache/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This package implements the server in the [remote cache RFC](rfcs/0001-remote-ca
44

55
The package contains no `vp run` client adapter. Cache keys, values, and blobs remain opaque. A successful lookup does not prove that a result is reusable; a client must validate its inputs and output archive.
66

7-
[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https%3A%2F%2Fgithub.com%2Fvoidzero-dev%2Fvite-task%2Ftree%2Fmain%2Fpackages%2Fremote-cache)
7+
[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https%3A%2F%2Fgithub.com%2Fvoidzero-dev%2Fvite-task%2Ftree%2Ffeat%2Fpublic-remote-cache%2Fpackages%2Fremote-cache)
88

99
**Start here:** [Deploy the service and bind your repository](docs/self-hosting.md#quick-start-deploy-to-cloudflare). The button creates a standalone repository and provisions storage. Set `CACHE_REPOSITORY` to your public GitHub repository and keep the default `free` profile. The guide covers build-token permissions, deployment checks, custom domains, and the current client-integration limitation.
1010

‎packages/remote-cache/docs/self-hosting.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This guide deploys the service in your Cloudflare account and gives your reposit
66

77
## Quick start: Deploy to Cloudflare
88

9-
[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https%3A%2F%2Fgithub.com%2Fvoidzero-dev%2Fvite-task%2Ftree%2Fmain%2Fpackages%2Fremote-cache)
9+
[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https%3A%2F%2Fgithub.com%2Fvoidzero-dev%2Fvite-task%2Ftree%2Ffeat%2Fpublic-remote-cache%2Fpackages%2Fremote-cache)
1010

1111
The button copies this package into a new GitHub repository in your account and connects it to Workers Builds. It provisions a Worker, a D1 database, and an R2 bucket. You do not need a local checkout or GitHub Actions secrets. The repository that hosts the Worker can differ from the application repository that uses its cache. See [Cloudflare's deployment-button guide](https://developers.cloudflare.com/workers/platform/deploy-buttons/).
1212

@@ -38,7 +38,7 @@ Keep the generated D1 ID and R2 name in `wrangler.jsonc`. Each build reconstruct
3838

3939
The automatic checks verify the new deployment ID, disabled HTTP caching, rejected anonymous uploads, invalid requests, and cache misses. They do not upload data or prove authorized GitHub OIDC writes. The [e2e plan](e2e-plan.md#deploy-to-cloudflare-button) covers the full acceptance checks.
4040

41-
The button targets the package on `main`. Before this change is merged, test the flow by supplying the package URL at the reviewed PR commit to Cloudflare's deployment page.
41+
The button temporarily targets `feat/public-remote-cache` for PR #718's live e2e test. Before marking the PR ready for review, restore the buttons in the root README, package README, and this guide to `main`, and remove this note. The CI button check rejects temporary branch URLs on a PR that is ready for review.
4242

4343
## CLI deployment
4444

0 commit comments

Comments
 (0)