From 3f23061831f4d60f4621d0799430ebfea75fa755 Mon Sep 17 00:00:00 2001 From: Finn <139806439+finn-block@users.noreply.github.com> Date: Mon, 3 Feb 2025 20:01:58 -0800 Subject: [PATCH] docs site: add PR previews (#865) --- .../workflows/deploy-docs-and-extensions.yml | 2 + .github/workflows/pr-website-preview.yml | 60 +++++++++++++++++++ documentation/docusaurus.config.ts | 2 +- 3 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/pr-website-preview.yml diff --git a/.github/workflows/deploy-docs-and-extensions.yml b/.github/workflows/deploy-docs-and-extensions.yml index b123fb5b..a9db84a9 100644 --- a/.github/workflows/deploy-docs-and-extensions.yml +++ b/.github/workflows/deploy-docs-and-extensions.yml @@ -13,6 +13,8 @@ on: jobs: deploy: runs-on: ubuntu-latest + permissions: + contents: write steps: - name: Checkout the branch diff --git a/.github/workflows/pr-website-preview.yml b/.github/workflows/pr-website-preview.yml new file mode 100644 index 00000000..9a9f91ec --- /dev/null +++ b/.github/workflows/pr-website-preview.yml @@ -0,0 +1,60 @@ +name: Documentation Site Preview + +on: + pull_request: + types: + - opened + - reopened + - synchronize + - closed + paths: + - 'documentation/**' + - 'extensions-site/**' + +concurrency: preview-${{ github.ref }} + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: Checkout the branch + uses: actions/checkout@v3 + + - name: Setup Node.js + uses: actions/setup-node@v3 + if: github.event.action != 'closed' + with: + node-version: 20 + + - name: Install dependencies and build docs + working-directory: ./documentation + if: github.event.action != 'closed' + env: + INKEEP_API_KEY: ${{ secrets.INKEEP_API_KEY }} + INKEEP_INTEGRATION_ID: ${{ secrets.INKEEP_INTEGRATION_ID }} + INKEEP_ORG_ID: ${{ secrets.INKEEP_ORG_ID }} + TARGET_PATH: "/goose/pr-preview/pr-${{ github.event.number }}/" + run: | + npm install + npm run build + + - name: Install dependencies and build extensions-site + working-directory: ./extensions-site + env: + VITE_BASENAME: "/goose/pr-preview/pr-${{ github.event.number }}/v1/extensions/" # Set the base URL here for the extensions site + run: | + npm install + npm run build + + - name: Combine builds into one directory + run: | + mkdir combined-build + cp -r documentation/build/* combined-build/ + mkdir -p combined-build/v1/extensions + cp -r extensions-site/build/client/* combined-build/v1/extensions/ + + - name: Deploy preview + uses: rossjrw/pr-preview-action@v1 + if: ${{ github.event.pull_request.head.repo.full_name == 'block/goose' }} + with: + source-dir: combined-build diff --git a/documentation/docusaurus.config.ts b/documentation/docusaurus.config.ts index f07fcf8a..17066272 100644 --- a/documentation/docusaurus.config.ts +++ b/documentation/docusaurus.config.ts @@ -20,7 +20,7 @@ const config: Config = { url: "https://block.github.io/", // Set the // pathname under which your site is served // For GitHub pages deployment, it is often '//' - baseUrl: "/goose/", + baseUrl: process.env.TARGET_PATH || "/goose/", // GitHub pages deployment config. // If you aren't using GitHub pages, you don't need these.