Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
78e04a7
Migrate from Netlify to Cloudflare Workers
matthewp Jun 9, 2026
6458343
Fix CI: approve workerd build script for pnpm
matthewp Jun 9, 2026
ea63f3a
Merge main into migrate-cloudflare
matthewp Jun 9, 2026
f305b5c
Allow workerd build script in pnpm-workspace.yaml
matthewp Jun 9, 2026
06e03b3
Trigger CI
matthewp Jun 9, 2026
37ec087
Increase Node.js heap size for Workers Builds
matthewp Jun 9, 2026
9b54083
Remove build command from wrangler config
matthewp Jun 9, 2026
2625f78
Add GitHub Actions deploy workflow with preview URLs
matthewp Jun 9, 2026
1705840
Trigger CI
matthewp Jun 9, 2026
116d5df
Fix preview URL domain
matthewp Jun 9, 2026
929a755
Trigger CI
matthewp Jun 9, 2026
d2566f6
Trigger CI
matthewp Jun 9, 2026
1e22831
Use GITHUB_HEAD_REF for preview site URL
matthewp Jun 9, 2026
5bfb1e5
Cache Astro build artifacts between CI runs
matthewp Jun 9, 2026
15d051b
Add deployment status to PR comment
matthewp Jun 9, 2026
a7db42e
Comment out 404 redirect unsupported by Cloudflare
matthewp Jun 9, 2026
ec11967
Fix worker name to 'docs'
matthewp Jun 9, 2026
b083fba
Cache OG images between builds
matthewp Jun 9, 2026
02b725c
Trigger CI to test OG cache
matthewp Jun 9, 2026
5dc8b2f
Review cleanup: remove deploy script, observability; add localized 40…
matthewp Jun 9, 2026
7bf0eeb
Fix ESLint: declare Worker globals
matthewp Jun 9, 2026
17ccfb0
Add ASSETS binding for Worker to fetch static assets
matthewp Jun 9, 2026
fef98c4
Use cloudflare/wrangler-action and add Worker docs
matthewp Jun 11, 2026
ff7a091
Disallow workerd build script
matthewp Jun 11, 2026
30b4701
Skip deploy and PR comments for fork PRs
matthewp Jun 11, 2026
dd50071
Deploy previews for fork PRs via workflow_run
matthewp Jun 12, 2026
22242e3
Address review feedback on deploy workflows
matthewp Jun 12, 2026
1162f5a
Support deploying version branches (v4, v5, v6)
matthewp Jun 12, 2026
b78e7f2
Add v7 to version branch deploy list
matthewp Jun 12, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
143 changes: 143 additions & 0 deletions .github/workflows/deploy-preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
name: Deploy Preview

on:
workflow_run:
workflows: ["Deploy"]
types: [completed]

permissions: {}

Comment thread
delucis marked this conversation as resolved.
# Cancel older preview runs for the same branch so a stale deploy doesn't
# overwrite the comment from a newer one.
concurrency:
group: preview-${{ github.event.workflow_run.head_branch }}
cancel-in-progress: true

jobs:
deploy-preview:
if: >-
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
pull-requests: write
steps:
- name: Download PR metadata
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: pr-metadata
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ github.token }}
path: pr-metadata

- name: Read PR metadata
id: metadata
run: |
echo "pr_number=$(cat pr-metadata/pr_number)" >> "$GITHUB_OUTPUT"
echo "preview_alias=$(cat pr-metadata/preview_alias)" >> "$GITHUB_OUTPUT"
echo "preview_url=$(cat pr-metadata/preview_url)" >> "$GITHUB_OUTPUT"

- name: Comment deployment in progress
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
const prNumber = parseInt('${{ steps.metadata.outputs.pr_number }}', 10);
const previewUrl = '${{ steps.metadata.outputs.preview_url }}';
const commitSHA = '${{ github.event.workflow_run.head_sha }}';
const runUrl = '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}';
const body = `**Preview deployment**\n\n`
+ `🔄 Deployment in progress...\n\n`
+ `- **Latest commit:** ${commitSHA}\n`
+ `- **Preview:** ${previewUrl}\n`
+ `- **Workflow run:** [View logs](${runUrl})`;
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
});
const existing = comments.find(c => c.user.login === 'github-actions[bot]' && c.body.includes('**Preview deployment**'));
if (existing) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existing.id,
body,
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
body,
});
}

- name: Download build output
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: build-output
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ github.token }}

- name: Deploy preview
uses: cloudflare/wrangler-action@9acf94ace14e7dc412b076f2c5c20b8ce93c79cd # v3.15.0
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
command: versions upload --preview-alias "${{ steps.metadata.outputs.preview_alias }}"

- name: Comment deployment complete
if: success()
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
const prNumber = parseInt('${{ steps.metadata.outputs.pr_number }}', 10);
const previewUrl = '${{ steps.metadata.outputs.preview_url }}';
const commitSHA = '${{ github.event.workflow_run.head_sha }}';
const runUrl = '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}';
const body = `**Preview deployment**\n\n`
+ `✅ Deployment complete!\n\n`
+ `- **Latest commit:** ${commitSHA}\n`
+ `- **Preview:** ${previewUrl}\n`
+ `- **Workflow run:** [View logs](${runUrl})`;
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
});
const existing = comments.find(c => c.user.login === 'github-actions[bot]' && c.body.includes('**Preview deployment**'));
if (existing) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existing.id,
body,
});
}

- name: Comment deployment failed
if: failure()
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
const prNumber = parseInt('${{ steps.metadata.outputs.pr_number }}', 10);
const commitSHA = '${{ github.event.workflow_run.head_sha }}';
const runUrl = '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}';
const body = `**Preview deployment**\n\n`
+ `❌ Deployment failed!\n\n`
+ `- **Latest commit:** ${commitSHA}\n`
+ `- **Workflow run:** [View logs](${runUrl})`;
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
});
const existing = comments.find(c => c.user.login === 'github-actions[bot]' && c.body.includes('**Preview deployment**'));
if (existing) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existing.id,
body,
});
}
83 changes: 83 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Deploy

on:
push:
branches: [main, v4, v5, v6, v7]
pull_request:

# Automatically cancel in-progress actions on the same branch
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}
cancel-in-progress: true

permissions: {}

env:
NODE_OPTIONS: "--max_old_space_size=8192"

jobs:
deploy:
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3

- name: Install Tools & Dependencies
uses: ./.github/actions/install

- name: Cache Astro build
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
path: |
node_modules/.astro
node_modules/.astro-og-canvas
key: astro-build-${{ hashFiles('src/**') }}
restore-keys: |
astro-build-

- name: Build
run: pnpm build

- name: Deploy
if: >-
github.ref == 'refs/heads/main' ||
github.ref == 'refs/heads/v4' ||
github.ref == 'refs/heads/v5' ||
github.ref == 'refs/heads/v6' ||
github.ref == 'refs/heads/v7'
uses: cloudflare/wrangler-action@9acf94ace14e7dc412b076f2c5c20b8ce93c79cd # v3.15.0
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
command: deploy

- name: Upload build output
if: github.event_name == 'pull_request'
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: build-output
path: |
dist/
worker.js
wrangler.jsonc

- name: Save PR metadata
if: github.event_name == 'pull_request'
run: |
mkdir -p pr-metadata
echo "${{ github.event.pull_request.number }}" > pr-metadata/pr_number
BRANCH="${{ github.head_ref }}"
# Sanitize branch name into a valid subdomain: lowercase, replace non-alphanumeric chars with hyphens, strip leading/trailing hyphens.
# Used as the subdomain for the preview URL, e.g. "my-branch.previews.docs.astro.build".
ALIAS=$(echo "$BRANCH" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9-]/-/g' | sed 's/^-//' | sed 's/-$//')
Comment thread
delucis marked this conversation as resolved.
echo "$ALIAS" > pr-metadata/preview_alias
echo "https://${ALIAS}.previews.docs.astro.build" > pr-metadata/preview_url

- name: Upload PR metadata
if: github.event_name == 'pull_request'
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: pr-metadata
path: pr-metadata/
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ sandbox.config.json
# macOS-specific files
.DS_Store

# Local Netlify folder
.netlify
# Local Wrangler folder
.wrangler

# Cached requests
.cache
Expand Down
8 changes: 5 additions & 3 deletions astro.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ import { starlightPluginSmokeTest } from './config/plugins/smoke-test';
import { rehypeTasklistEnhancer } from './config/plugins/rehype-tasklist-enhancer';
import { remarkFallbackLang } from './config/plugins/remark-fallback-lang';

/* https://docs.netlify.com/configure-builds/environment-variables/#read-only-variables */
const NETLIFY_PREVIEW_SITE = process.env.CONTEXT !== 'production' && process.env.DEPLOY_PRIME_URL;
const previewBranch = process.env.GITHUB_HEAD_REF;
const previewSite = previewBranch
? `https://${previewBranch}.previews.docs.astro.build/`
: undefined;

const site = NETLIFY_PREVIEW_SITE || 'https://docs.astro.build/';
const site = previewSite || 'https://docs.astro.build/';

// https://astro.build/config
export default defineConfig({
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"lint:slugcheck": "node ./scripts/lint-slugcheck.mjs",
"lint:eslint": "eslint .",
"lint:ja": "textlint --cache --config .textlintrc.ja.json src/content/docs/ja/**/*.{md,mdx}",
"netlify:build": "pnpm ${NETLIFY_BUILD_SCRIPT:-build}",
"lunaria:build": "node --experimental-transform-types ./scripts/lunaria.mts"
},
"devDependencies": {
Expand Down Expand Up @@ -54,7 +53,8 @@
"typescript": "6.0.3",
"typescript-eslint": "^8.59.3",
"unified": "^11.0.5",
"unist-util-visit": "^5.1.0"
"unist-util-visit": "^5.1.0",
"wrangler": "^4.88.0"
},
"dependencies": {
"@astrojs/check": "^0.9.9",
Expand Down
Loading
Loading