From 80e42d765473172a7f19ca4c024791d4d15d2c8a Mon Sep 17 00:00:00 2001 From: Alex Fornuto Date: Mon, 6 May 2024 12:13:37 -0500 Subject: [PATCH 1/4] init preview builds for PRs --- .github/workflows/deploy.yml | 8 ++++++- .github/workflows/pr-preview.yml | 40 ++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/pr-preview.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 2b89e25..6e9cb5a 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -49,4 +49,10 @@ jobs: steps: - name: Deploy to GitHub Pages id: deployment - uses: actions/deploy-pages@v4 + uses: JamesIves/github-pages-deploy-action@v4 + with: + clean-exclude: pr-preview/ + with: + folder: build + with: + force: false diff --git a/.github/workflows/pr-preview.yml b/.github/workflows/pr-preview.yml new file mode 100644 index 0000000..5bd289c --- /dev/null +++ b/.github/workflows/pr-preview.yml @@ -0,0 +1,40 @@ +# .github/workflows/preview.yml +name: Deploy PR previews + +on: + pull_request: + types: + - opened + - reopened + - synchronize + - closed + label: + types: + - preview + +concurrency: preview-${{ github.ref }} + +jobs: + deploy-preview: + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/setup-node@v4 + with: + node-version: 18 + cache: yarn + - name: Get submodules + run: git submodule init && git submodule update --remote --merge + - name: Install and Build + if: github.event.action != 'closed' # You might want to skip the build if the PR has been closed + run: | + yarn install --frozen-lockfile + yarn build + + - name: Deploy preview + uses: rossjrw/pr-preview-action@v1 + with: + source-dir: ./build/ \ No newline at end of file From 1941b1aa5f34f320e14acfaf265f9961e3b250e8 Mon Sep 17 00:00:00 2001 From: Alex Fornuto Date: Mon, 6 May 2024 12:41:26 -0500 Subject: [PATCH 2/4] fix baseURL for previews --- .github/workflows/deploy.yml | 2 +- .github/workflows/pr-preview.yml | 5 ++++- docusaurus.config.js | 2 +- kc | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 6e9cb5a..1f16b16 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -24,7 +24,7 @@ jobs: - name: Install dependencies run: yarn install --frozen-lockfile - name: Build website - run: yarn build + run: BASEURL='/' yarn build - name: Upload Build Artifact uses: actions/upload-pages-artifact@v3 diff --git a/.github/workflows/pr-preview.yml b/.github/workflows/pr-preview.yml index 5bd289c..33ee9b2 100644 --- a/.github/workflows/pr-preview.yml +++ b/.github/workflows/pr-preview.yml @@ -30,9 +30,12 @@ jobs: run: git submodule init && git submodule update --remote --merge - name: Install and Build if: github.event.action != 'closed' # You might want to skip the build if the PR has been closed + env: + pr: ${{ github.event.number }} run: | + echo "pr=$pr" >> $GITHUB_ENV yarn install --frozen-lockfile - yarn build + BASEURL='/pr-preview/pr-$pr' yarn build - name: Deploy preview uses: rossjrw/pr-preview-action@v1 diff --git a/docusaurus.config.js b/docusaurus.config.js index 9631f72..756a6da 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -17,7 +17,7 @@ const config = { url: 'https://keychain.org', // Set the // pathname under which your site is served // For GitHub pages deployment, it is often '//' - baseUrl: '/', + baseUrl: process.env.BASEURL, // GitHub pages deployment config. // If you aren't using GitHub pages, you don't need these. diff --git a/kc b/kc index 4733361..0e646d5 160000 --- a/kc +++ b/kc @@ -1 +1 @@ -Subproject commit 473336106118b08b1468be77e01b88ad55314024 +Subproject commit 0e646d5cd3413502f43f9a46fbfb17046cd0b999 From 524885c12609159fef24d82ec89327f3349a27b7 Mon Sep 17 00:00:00 2001 From: Alex Fornuto Date: Mon, 6 May 2024 12:43:08 -0500 Subject: [PATCH 3/4] remove redundant workflow --- .github/workflows/test-deploy.yml | 27 --------------------------- 1 file changed, 27 deletions(-) delete mode 100644 .github/workflows/test-deploy.yml diff --git a/.github/workflows/test-deploy.yml b/.github/workflows/test-deploy.yml deleted file mode 100644 index 46cabc3..0000000 --- a/.github/workflows/test-deploy.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Test deployment - -on: - pull_request: - branches: - - main - # Review gh actions docs if you want to further define triggers, paths, etc - # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on - -jobs: - test-deploy: - name: Test deployment - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - uses: actions/setup-node@v4 - with: - node-version: 18 - cache: yarn - - name: Get submodules - run: git submodule init && git submodule update --remote --merge - - name: Install dependencies - run: yarn install --frozen-lockfile - - name: Test build website - run: yarn build From 0cd72eb6d5cbb83ec2e3d6189c32f8ddd1ae06c5 Mon Sep 17 00:00:00 2001 From: Alex Fornuto Date: Mon, 6 May 2024 12:43:54 -0500 Subject: [PATCH 4/4] syntax fix --- .github/workflows/pr-preview.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-preview.yml b/.github/workflows/pr-preview.yml index 33ee9b2..1300966 100644 --- a/.github/workflows/pr-preview.yml +++ b/.github/workflows/pr-preview.yml @@ -33,7 +33,7 @@ jobs: env: pr: ${{ github.event.number }} run: | - echo "pr=$pr" >> $GITHUB_ENV + echo "pr=$pr" >> $GITHUB_ENV yarn install --frozen-lockfile BASEURL='/pr-preview/pr-$pr' yarn build