Skip to content

Commit bbfcd64

Browse files
authored
[Docs Site] Move show-changed-files to bin and fix workflow condition (#19784)
1 parent abd5300 commit bbfcd64

27 files changed

+1046
-3550
lines changed

.github/actions/show-changed-files/package-lock.json

Lines changed: 0 additions & 859 deletions
This file was deleted.

.github/actions/show-changed-files/package.json

Lines changed: 0 additions & 13 deletions
This file was deleted.

.github/actions/show-changed-files/tsconfig.json

Lines changed: 0 additions & 21 deletions
This file was deleted.

.github/workflows/publish-preview.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
name: Build
3333
env:
3434
NODE_OPTIONS: --max-old-space-size=4096
35-
- run: npx wrangler versions upload -c ./wrangler-workers.toml
35+
- run: npx wrangler versions upload
3636
name: Deploy to Cloudflare Workers
3737
env:
3838
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}

.github/workflows/publish-production.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
name: Build
2929
env:
3030
NODE_OPTIONS: --max-old-space-size=4096
31-
- run: npx wrangler deploy -c ./wrangler-workers.toml
31+
- run: npx wrangler deploy
3232
name: Deploy to Cloudflare Workers
3333
env:
3434
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}

.github/workflows/show-changed-files.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,15 @@ on:
1313
jobs:
1414
changed-files-links:
1515
name: Show Changed Files
16-
if: github.event.issue.pull_request && github.event.issue.state == 'open' && github.event.comment.user.id == 41898282 && contains(github.event.comment.body, '**Preview URL**')
16+
if: github.event.issue.pull_request && github.event.issue.state == 'open' && github.event.comment.user.id == 41898282 && contains(github.event.comment.body, '**Preview URL:**')
1717
runs-on: ubuntu-latest
1818
steps:
1919
- uses: actions/checkout@v4
20-
- run: cd ./.github/actions/show-changed-files
2120
- uses: actions/setup-node@v4
2221
with:
2322
node-version: 22
2423
cache: "npm"
2524
- run: npm ci
26-
- run: npx tsx index.ts
25+
- run: npx tsx bin/show-changed-files/index.ts
2726
env:
2827
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.prettierignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,3 @@ dist
55
public/_redirects
66
public/analytics/static/downloads/main.css
77
src/content/workers-ai-models/*.json
8-
tests/fixtures/openapi.json
File renamed without changes.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export const GITHUB_ACTIONS_BOT_ID = 41898282;
2+
export const DOCS_BASE_URL = "https://developers.cloudflare.com";
3+
export const CONTENT_BASE_PATH = "src/content";
4+
export const EXISTING_COMMENT_SUBSTRING = "| Original Link | Updated Link |";
5+
export const PREVIEW_URL_REGEX = /^\*\*Preview URL:\*\* (.*)$/m;
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import { describe, expect, test } from "vitest";
2+
import { DOCS_BASE_URL, PREVIEW_URL_REGEX } from "./constants";
3+
import { filenameToPath } from "./util";
4+
5+
test("PREVIEW_URL_REGEX", () => {
6+
const comment =
7+
"**Preview URL:** https://ac148943-cloudflare-docs.cloudflare-docs.workers.dev";
8+
const matches = comment.match(PREVIEW_URL_REGEX);
9+
10+
expect(matches).toBeDefined();
11+
expect(matches![1]).toEqual(
12+
"https://ac148943-cloudflare-docs.cloudflare-docs.workers.dev",
13+
);
14+
});
15+
16+
describe("filenameToPath", () => {
17+
test("index", () => {
18+
expect(filenameToPath("src/content/docs/workers/index.mdx")).toEqual(
19+
"workers/",
20+
);
21+
});
22+
23+
test("index base", () => {
24+
expect(
25+
`${DOCS_BASE_URL}/${filenameToPath("src/content/docs/workers/index.mdx")}`,
26+
).toEqual("https://developers.cloudflare.com/workers/");
27+
});
28+
29+
test("folder", () => {
30+
expect(
31+
filenameToPath("src/content/docs/workers/get-started/cli.mdx"),
32+
).toEqual("workers/get-started/cli/");
33+
});
34+
35+
test("1.1.1.1", () => {
36+
expect(filenameToPath("src/content/docs/1111/index.mdx")).toEqual(
37+
"1.1.1.1/",
38+
);
39+
});
40+
41+
test("changelog", () => {
42+
expect(
43+
filenameToPath("src/content/changelogs-next/2025-02-05-title.mdx"),
44+
).toEqual("changelog/2025-02-05-title/");
45+
});
46+
47+
test("changelog base", () => {
48+
expect(
49+
`${DOCS_BASE_URL}/${filenameToPath("src/content/changelogs-next/2025-02-05-title.mdx")}`,
50+
).toEqual("https://developers.cloudflare.com/changelog/2025-02-05-title/");
51+
});
52+
});

0 commit comments

Comments
 (0)