From 2b9881e1c21c855d32721d805d7757333f261c69 Mon Sep 17 00:00:00 2001 From: JasonKrik Date: Tue, 10 Jun 2025 14:35:25 +0200 Subject: [PATCH 1/6] feat: add GitHub workflows for deploying documentation previews to Cloudflare Pages --- .github/workflows/deploy_preview.yml | 42 ++++++++++++++++++++++++++++ .github/workflows/deploy_prod.yml | 42 ++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 .github/workflows/deploy_preview.yml create mode 100644 .github/workflows/deploy_prod.yml diff --git a/.github/workflows/deploy_preview.yml b/.github/workflows/deploy_preview.yml new file mode 100644 index 0000000..d59776f --- /dev/null +++ b/.github/workflows/deploy_preview.yml @@ -0,0 +1,42 @@ +name: Deploy Documentation Preview + +on: + workflow_dispatch: + inputs: + comment: + description: 'Deployment Documentation' + required: false + default: 'Manual preview deployment' + +jobs: + build-and-deploy: + if: github.ref == 'refs/heads/main' + runs-on: ubuntu-latest + permissions: + contents: read + deployments: write + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: npm + + - name: Install dependencies + run: | + npm install + + - name: Build frontend + run: npm run build + + - name: Deploy to Cloudflare Pages + uses: cloudflare/wrangler-action@v3 + with: + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} + accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + command: pages deploy out --project-name=deploystack-docs --branch=main + gitHubToken: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/deploy_prod.yml b/.github/workflows/deploy_prod.yml new file mode 100644 index 0000000..450657f --- /dev/null +++ b/.github/workflows/deploy_prod.yml @@ -0,0 +1,42 @@ +name: Deploy Documentation Preview + +on: + workflow_dispatch: + inputs: + comment: + description: 'Deployment Documentation' + required: false + default: 'Manual preview deployment' + +jobs: + build-and-deploy: + if: github.ref == 'refs/heads/prod' + runs-on: ubuntu-latest + permissions: + contents: read + deployments: write + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: npm + + - name: Install dependencies + run: | + npm install + + - name: Build frontend + run: npm run build + + - name: Deploy to Cloudflare Pages + uses: cloudflare/wrangler-action@v3 + with: + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} + accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + command: pages deploy out --project-name=deploystack-docs --branch=prod + gitHubToken: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From 7b0a5e417c2e48bc0dd2399439d0a63149e57548 Mon Sep 17 00:00:00 2001 From: JasonKrik Date: Tue, 10 Jun 2025 14:41:38 +0200 Subject: [PATCH 2/6] fix: update GitHub workflows to allow manual triggering and improve branch checks --- .github/workflows/deploy_preview.yml | 2 +- .github/workflows/deploy_prod.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy_preview.yml b/.github/workflows/deploy_preview.yml index d59776f..91a1ff1 100644 --- a/.github/workflows/deploy_preview.yml +++ b/.github/workflows/deploy_preview.yml @@ -10,7 +10,7 @@ on: jobs: build-and-deploy: - if: github.ref == 'refs/heads/main' + if: github.ref_name == 'main' || github.event_name == 'workflow_dispatch' runs-on: ubuntu-latest permissions: contents: read diff --git a/.github/workflows/deploy_prod.yml b/.github/workflows/deploy_prod.yml index 450657f..29d6d8a 100644 --- a/.github/workflows/deploy_prod.yml +++ b/.github/workflows/deploy_prod.yml @@ -10,7 +10,7 @@ on: jobs: build-and-deploy: - if: github.ref == 'refs/heads/prod' + if: github.ref_name == 'prod' || github.event_name == 'workflow_dispatch' runs-on: ubuntu-latest permissions: contents: read From 4dcb441e8d9c3207e65ef2bb286b62f0a0902fbc Mon Sep 17 00:00:00 2001 From: JasonKrik Date: Tue, 10 Jun 2025 14:46:18 +0200 Subject: [PATCH 3/6] fix: update deployment commands in GitHub workflows to use the correct output directory --- .github/workflows/deploy_preview.yml | 2 +- .github/workflows/deploy_prod.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy_preview.yml b/.github/workflows/deploy_preview.yml index 91a1ff1..162891c 100644 --- a/.github/workflows/deploy_preview.yml +++ b/.github/workflows/deploy_preview.yml @@ -38,5 +38,5 @@ jobs: with: apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} - command: pages deploy out --project-name=deploystack-docs --branch=main + command: pages deploy .next --project-name=deploystack-docs --branch=main gitHubToken: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/deploy_prod.yml b/.github/workflows/deploy_prod.yml index 29d6d8a..48f60dd 100644 --- a/.github/workflows/deploy_prod.yml +++ b/.github/workflows/deploy_prod.yml @@ -38,5 +38,5 @@ jobs: with: apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} - command: pages deploy out --project-name=deploystack-docs --branch=prod + command: pages deploy .next --project-name=deploystack-docs --branch=prod gitHubToken: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From 554689866d02ad30c540cfed53e6bc2283dfd3bd Mon Sep 17 00:00:00 2001 From: JasonKrik Date: Tue, 10 Jun 2025 14:47:23 +0200 Subject: [PATCH 4/6] fix: rename workflow for deploying documentation from preview to production --- .github/workflows/deploy_prod.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy_prod.yml b/.github/workflows/deploy_prod.yml index 48f60dd..34641e5 100644 --- a/.github/workflows/deploy_prod.yml +++ b/.github/workflows/deploy_prod.yml @@ -1,4 +1,4 @@ -name: Deploy Documentation Preview +name: Deploy Documentation Production on: workflow_dispatch: @@ -6,7 +6,7 @@ on: comment: description: 'Deployment Documentation' required: false - default: 'Manual preview deployment' + default: 'Manual Production deployment' jobs: build-and-deploy: From c719c93a862494962ea0c87420f7f37d5a17e863 Mon Sep 17 00:00:00 2001 From: JasonKrik Date: Tue, 10 Jun 2025 15:22:16 +0200 Subject: [PATCH 5/6] fix: update deployment commands in workflows to use the correct output directory and remove unnecessary files --- .github/workflows/deploy_preview.yml | 4 ++-- .github/workflows/deploy_prod.yml | 4 ++-- .gitignore | 3 ++- app/api/search/route.ts | 4 ---- app/docs/sitemap.xml/route.ts | 3 +++ next.config.mjs | 9 +++++---- 6 files changed, 14 insertions(+), 13 deletions(-) delete mode 100644 app/api/search/route.ts diff --git a/.github/workflows/deploy_preview.yml b/.github/workflows/deploy_preview.yml index 162891c..1843939 100644 --- a/.github/workflows/deploy_preview.yml +++ b/.github/workflows/deploy_preview.yml @@ -38,5 +38,5 @@ jobs: with: apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} - command: pages deploy .next --project-name=deploystack-docs --branch=main - gitHubToken: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + command: pages deploy out --project-name=deploystack-docs --branch=main + gitHubToken: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/deploy_prod.yml b/.github/workflows/deploy_prod.yml index 34641e5..7ec7f5c 100644 --- a/.github/workflows/deploy_prod.yml +++ b/.github/workflows/deploy_prod.yml @@ -38,5 +38,5 @@ jobs: with: apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} - command: pages deploy .next --project-name=deploystack-docs --branch=prod - gitHubToken: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + command: pages deploy out --project-name=deploystack-docs --branch=prod + gitHubToken: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 707896b..c870832 100644 --- a/.gitignore +++ b/.gitignore @@ -71,4 +71,5 @@ coverage/ .jest/ ._*.mdx -._*.ts \ No newline at end of file +._*.ts +out/ diff --git a/app/api/search/route.ts b/app/api/search/route.ts deleted file mode 100644 index 0a57c2b..0000000 --- a/app/api/search/route.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { source } from '../../../lib/source'; -import { createFromSource } from 'fumadocs-core/search/server'; - -export const { GET } = createFromSource(source); diff --git a/app/docs/sitemap.xml/route.ts b/app/docs/sitemap.xml/route.ts index b05ed9c..25f1e6e 100644 --- a/app/docs/sitemap.xml/route.ts +++ b/app/docs/sitemap.xml/route.ts @@ -1,6 +1,9 @@ import { source } from '@/lib/source'; import { getCanonicalUrl } from '@/lib/seo-utils'; +export const dynamic = 'force-static'; +export const revalidate = false; + export async function GET() { const pages = source.getPages(); diff --git a/next.config.mjs b/next.config.mjs index c4e6ede..2c29d36 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -5,12 +5,13 @@ const withMDX = createMDX(); /** @type {import('next').NextConfig} */ const config = { reactStrictMode: true, + output: 'export', // Enable static HTML export + trailingSlash: true, // Required for static export + images: { + unoptimized: true // Required for static export + }, // Sitemap is now handled by app/docs/sitemap.xml/route.ts // If you have other Next.js configurations, add them here - // For example, if you need to serve static files from the 'public' directory - // and your images are in 'docs/assets/images', you might need to configure images domain - // or ensure they are moved to 'public/docs/assets/images' and referenced accordingly. - // For now, we'll stick to the basic config. }; export default withMDX(config); From d8e4ed3820e50b4b5156339b6c7e8b2b046c7656 Mon Sep 17 00:00:00 2001 From: JasonKrik Date: Tue, 10 Jun 2025 18:21:17 +0200 Subject: [PATCH 6/6] fixed build command --- next.config.mjs | 2 ++ package.json | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/next.config.mjs b/next.config.mjs index 2c29d36..336687c 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -7,6 +7,8 @@ const config = { reactStrictMode: true, output: 'export', // Enable static HTML export trailingSlash: true, // Required for static export + basePath: '/docs', // Set base path for the application + assetPrefix: '/docs', // Ensure assets are also prefixed with /docs images: { unoptimized: true // Required for static export }, diff --git a/package.json b/package.json index 62fb72c..354b893 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,8 @@ "private": true, "scripts": { "dev": "next dev", - "build": "next build", + "build": "next build && npm run move-assets", + "move-assets": "mkdir -p out/docs/_next && cp -r out/_next/* out/docs/_next/ && rm -rf out/_next", "start": "next start", "lint:md": "npx markdownlint-cli2 '**/*.md' '#node_modules' '#.github'", "lint:links": "node check-links.js",