From ee59b74af1abdf1e8c2fe89a16d2ada19bec185c Mon Sep 17 00:00:00 2001 From: quexeky Date: Sat, 2 Aug 2025 22:34:56 +1000 Subject: [PATCH] chore: add cloudflare-pr-testing workflow Signed-off-by: quexeky --- .github/workflows/cloudflare-pr-testing.yml | 51 +++++++++++++++++++++ docusaurus.config.ts | 2 +- 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/cloudflare-pr-testing.yml diff --git a/.github/workflows/cloudflare-pr-testing.yml b/.github/workflows/cloudflare-pr-testing.yml new file mode 100644 index 0000000..a5b2b0e --- /dev/null +++ b/.github/workflows/cloudflare-pr-testing.yml @@ -0,0 +1,51 @@ +name: Deploy PR to Cloudflare Pages + +on: + pull_request: + types: [opened, synchronize, reopened] + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + # Build and deploy the preview. + deploy-preview: + runs-on: ubuntu-latest + name: Deploy to Cloudflare Pages + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: 18 + cache: yarn + - name: Get PR number + id: pr_number + run: echo "PR_NUMBER=${{ github.event.pull_request.number }}" >> $GITHUB_ENV + - name: Configure Docusaurus for PR deploy + run: sed -i 's/BASE_URL/${{ env.PR_NUMBER }}' docusaurus.config.ts + + - name: Install dependencies + run: yarn install --frozen-lockfile + + - name: Build + run: yarn build + + - name: Deploy to Cloudflare Pages + id: deploy + uses: cloudflare/wrangler-action@v3.14.1 + with: + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} + accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + command: pages deploy build --project-name=${{ env.PR_NUMBER }} + + + outputs: + previewUrl: https://${{ env.PR_NUMBER }}.test.quexeky.dev + diff --git a/docusaurus.config.ts b/docusaurus.config.ts index 8422700..0cf57d9 100644 --- a/docusaurus.config.ts +++ b/docusaurus.config.ts @@ -10,7 +10,7 @@ const config: Config = { favicon: "/drop.svg", // Set the production url of your site here - url: "https://docs.droposs.org", + url: "BASE_URL", // Set the // pathname under which your site is served // For GitHub pages deployment, it is often '//' baseUrl: "/",