From b5fc53f1faeb238d03951b86ad28b985b9406fc8 Mon Sep 17 00:00:00 2001 From: Paul Meyer <49727155+katexochen@users.noreply.github.com> Date: Thu, 14 Mar 2024 13:59:13 +0100 Subject: [PATCH 1/5] contrast-docs: make baseUrl overridable Signed-off-by: Paul Meyer <49727155+katexochen@users.noreply.github.com> --- packages/by-name/contrast-docs/package.nix | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/by-name/contrast-docs/package.nix b/packages/by-name/contrast-docs/package.nix index f7668f7cf5..a188986261 100644 --- a/packages/by-name/contrast-docs/package.nix +++ b/packages/by-name/contrast-docs/package.nix @@ -1,6 +1,10 @@ -{ fetchYarnDeps +{ lib +, fetchYarnDeps , mkYarnPackage , contrast + + # Configure the base URL when deploying previews under a subpath +, docusaurusBaseUrl ? "" }: mkYarnPackage rec { @@ -18,6 +22,8 @@ mkYarnPackage rec { configurePhase = '' cp -r $node_modules node_modules chmod +w node_modules + '' + lib.optionalString (docusaurusBaseUrl != "") '' + sed -i "s|baseUrl: '/contrast/',|baseUrl: '${docusaurusBaseUrl}',|" docusaurus.config.js ''; buildPhase = '' From 2e967c66e9707b56170780397b0e812aa26cc350 Mon Sep 17 00:00:00 2001 From: Paul Meyer <49727155+katexochen@users.noreply.github.com> Date: Mon, 18 Mar 2024 16:08:45 +0100 Subject: [PATCH 2/5] ci: switch actions for deploying docs Signed-off-by: Paul Meyer <49727155+katexochen@users.noreply.github.com> --- .github/workflows/docs_publish.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/docs_publish.yml b/.github/workflows/docs_publish.yml index 33356b387d..286944c4a3 100644 --- a/.github/workflows/docs_publish.yml +++ b/.github/workflows/docs_publish.yml @@ -23,13 +23,13 @@ jobs: with: githubToken: ${{ secrets.GITHUB_TOKEN }} cachixToken: ${{ secrets.CACHIX_AUTH_TOKEN }} - - name: Build website + - name: Build production website run: | nix build .#contrast-docs - - name: Deploy to GitHub Pages - uses: peaceiris/actions-gh-pages@373f7f263a76c20808c831209c920827a82a2847 # v3.9.3 + - name: Publish docs to GitHub Pages + uses: JamesIves/github-pages-deploy-action@65b5dfd4f5bcd3a7403bbc2959c144256167464e # v4.5.0 with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./result - user_name: edgelessci - user_email: edgelessci@users.noreply.github.com + folder: ./result + branch: gh-pages + clean-exclude: pr-preview + force: false From ee759b0ef8cb53d363b880c022c1e216ff8a8900 Mon Sep 17 00:00:00 2001 From: Paul Meyer <49727155+katexochen@users.noreply.github.com> Date: Mon, 18 Mar 2024 16:22:37 +0100 Subject: [PATCH 3/5] ci: deploy docs preview on pr Signed-off-by: Paul Meyer <49727155+katexochen@users.noreply.github.com> --- .github/workflows/docs_publish.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/.github/workflows/docs_publish.yml b/.github/workflows/docs_publish.yml index 286944c4a3..c757faa936 100644 --- a/.github/workflows/docs_publish.yml +++ b/.github/workflows/docs_publish.yml @@ -9,27 +9,53 @@ on: - docs/** - .github/workflows/docs_publish.yml - packages/contrast-docs/** + pull_request: + types: + - opened + - reopened + - synchronize + - closed + paths: + - docs/** + - .github/workflows/docs_publish.yml + - packages/contrast-docs/** permissions: contents: write + pull-requests: write jobs: deploy: name: Publish docs to GitHub Pages runs-on: ubuntu-22.04 + env: + PREVIEW: ${{ github.event_name == 'pull_request' && github.ref_name != 'main' }} steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - uses: ./.github/actions/setup_nix with: githubToken: ${{ secrets.GITHUB_TOKEN }} cachixToken: ${{ secrets.CACHIX_AUTH_TOKEN }} + - name: Build production website + if: (!env.PREVIEW) run: | nix build .#contrast-docs - name: Publish docs to GitHub Pages + if: (!env.PREVIEW) uses: JamesIves/github-pages-deploy-action@65b5dfd4f5bcd3a7403bbc2959c144256167464e # v4.5.0 with: folder: ./result branch: gh-pages clean-exclude: pr-preview force: false + + - name: Build preview website + if: env.PREVIEW + run: | + nix build --impure --expr "(builtins.getFlake \"git+file://$(pwd)?shallow=1\").outputs.legacyPackages.x86_64-linux.contrast-docs.override { docusaurusBaseUrl = \"contrast/pr-preview/pr-${{ github.event.number }}\"; }" + - name: Deploy preview + if: env.PREVIEW + uses: rossjrw/pr-preview-action@v1 + with: + source-dir: ./result From cf9ab0128e8b2bc4bf8d05421a52f1edee824db1 Mon Sep 17 00:00:00 2001 From: Paul Meyer <49727155+katexochen@users.noreply.github.com> Date: Mon, 18 Mar 2024 17:33:02 +0100 Subject: [PATCH 4/5] docs: remove cname Signed-off-by: Paul Meyer <49727155+katexochen@users.noreply.github.com> --- docs/CNAME | 1 - packages/by-name/contrast-docs/package.nix | 1 - 2 files changed, 2 deletions(-) delete mode 100644 docs/CNAME diff --git a/docs/CNAME b/docs/CNAME deleted file mode 100644 index da44318f88..0000000000 --- a/docs/CNAME +++ /dev/null @@ -1 +0,0 @@ -contrast-docs.edgeless.systems diff --git a/packages/by-name/contrast-docs/package.nix b/packages/by-name/contrast-docs/package.nix index a188986261..f496ae6d7f 100644 --- a/packages/by-name/contrast-docs/package.nix +++ b/packages/by-name/contrast-docs/package.nix @@ -36,6 +36,5 @@ mkYarnPackage rec { installPhase = '' mkdir -p $out cp -R build/* $out - cp CNAME $out ''; } From 79812bc099f48dbfd7298a423f8c425ed5e7da64 Mon Sep 17 00:00:00 2001 From: Paul Meyer <49727155+katexochen@users.noreply.github.com> Date: Mon, 18 Mar 2024 17:44:05 +0100 Subject: [PATCH 5/5] docs: remove _redirects Signed-off-by: Paul Meyer <49727155+katexochen@users.noreply.github.com> --- docs/static/_redirects | 1 - 1 file changed, 1 deletion(-) delete mode 100644 docs/static/_redirects diff --git a/docs/static/_redirects b/docs/static/_redirects deleted file mode 100644 index ad53a9a14b..0000000000 --- a/docs/static/_redirects +++ /dev/null @@ -1 +0,0 @@ -/contrast/* /:splat 200!