From 1552896b120e2bf60a6cdf61832c5e1b5f2a2abc Mon Sep 17 00:00:00 2001 From: Greg Martin Date: Thu, 6 Nov 2025 09:54:12 -0500 Subject: [PATCH 1/8] build: update pr-preview workflow to support deploy source actions --- .github/workflows/preview.yml | 43 ++++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index b263379f9..bf55487a9 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -9,11 +9,14 @@ on: - synchronize - closed -concurrency: preview-${{ github.ref }} +concurrency: preview-${{ github.event.number }} + +permissions: + contents: write jobs: deploy-preview: - if: ${{ github.actor != 'dependabot[bot]' }} + if: ${{ github.event.action != 'closed' && github.actor != 'dependabot[bot]' }} runs-on: ubuntu-latest steps: - name: Checkout Code @@ -52,10 +55,34 @@ jobs: - name: Build Docs run: yarn build:storybook:ci - - name: Deploy preview - uses: rossjrw/pr-preview-action@9f77b1d057b494e662c50b8ca40ecc63f21e0887 + - name: Deploy PR Preview + uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: dist/storybook + destination_dir: pr-preview/pr-${{ github.event.number }} + keep_files: true + + cleanup-preview: + if: ${{ github.event.action == 'closed' && github.actor != 'dependabot[bot]' }} + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Checkout gh-pages + uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 with: - source-dir: dist/storybook - preview-branch: gh-pages - umbrella-dir: pr-preview - action: auto + ref: gh-pages + + - name: Remove PR preview + run: | + if [ -d "pr-preview/pr-${{ github.event.number }}" ]; then + rm -rf pr-preview/pr-${{ github.event.number }} + git config user.email ${{ secrets.GH_EMAIL }} + git config user.name ${{ secrets.GH_USER }} + git add . + git commit -m "Remove preview for PR #${{ github.event.number }}" + git push + else + echo "Preview directory not found, nothing to clean up" + fi From c2d3ca8f632dc93d5370da09ad68f4d884f2bfda Mon Sep 17 00:00:00 2001 From: Greg Martin Date: Thu, 6 Nov 2025 10:07:44 -0500 Subject: [PATCH 2/8] build: update pr-preview workflow to provide link to preview when available --- .github/workflows/preview.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index bf55487a9..afbdedb4c 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -13,6 +13,7 @@ concurrency: preview-${{ github.event.number }} permissions: contents: write + pull-requests: write jobs: deploy-preview: @@ -63,6 +64,16 @@ jobs: destination_dir: pr-preview/pr-${{ github.event.number }} keep_files: true + - name: Comment PR + uses: actions/github-script@35b1cdd1b2c1fc704b1cd442536d6de4654e9c4d # v7.1.0 + with: + script: | + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: 'šŸš€ **Preview deployed!**\n\nšŸ“– [View Storybook Preview](https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/pr-preview/pr-${{ github.event.number }}/)' }) + cleanup-preview: if: ${{ github.event.action == 'closed' && github.actor != 'dependabot[bot]' }} runs-on: ubuntu-latest From 7d6da2e7e0480b27d16f25dc14052e8cfa432b67 Mon Sep 17 00:00:00 2001 From: Greg Martin Date: Thu, 6 Nov 2025 10:14:26 -0500 Subject: [PATCH 3/8] fix: use correct sha for github-script in pr-preview workflow --- .github/workflows/preview.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index afbdedb4c..4515d33d1 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -65,7 +65,7 @@ jobs: keep_files: true - name: Comment PR - uses: actions/github-script@35b1cdd1b2c1fc704b1cd442536d6de4654e9c4d # v7.1.0 + uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0 with: script: | github.rest.issues.createComment({ From 75435104539445962773a186886ceabcaf55c1b9 Mon Sep 17 00:00:00 2001 From: Greg Martin Date: Thu, 6 Nov 2025 10:47:41 -0500 Subject: [PATCH 4/8] fix: set storybook_base_path in preview.yml --- .github/workflows/preview.yml | 2 ++ apps/element-storybook/.storybook/main.ts | 14 +++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 4515d33d1..0856a1d6a 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -55,6 +55,8 @@ jobs: - name: Build Docs run: yarn build:storybook:ci + env: + STORYBOOK_BASE_PATH: /pr-preview/pr-${{ github.event.number }} - name: Deploy PR Preview uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0 diff --git a/apps/element-storybook/.storybook/main.ts b/apps/element-storybook/.storybook/main.ts index c134ea2dc..516184f57 100644 --- a/apps/element-storybook/.storybook/main.ts +++ b/apps/element-storybook/.storybook/main.ts @@ -53,7 +53,19 @@ const config: StorybookConfig = { storyStoreV7: false }, - docs: {} + docs: {}, + + managerHead: (head) => ` + ${head} + + `, + + viteFinal: async (config) => { + if (process.env.STORYBOOK_BASE_PATH) { + config.base = process.env.STORYBOOK_BASE_PATH + '/'; + } + return config; + } }; export default config; From 56aa26aadab6ed754f29c4b7ddb1d1cf2424d9e9 Mon Sep 17 00:00:00 2001 From: Greg Martin Date: Thu, 6 Nov 2025 10:59:26 -0500 Subject: [PATCH 5/8] fix: set storybook_base_path in preview.yml --- apps/element-storybook/.storybook/main.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/element-storybook/.storybook/main.ts b/apps/element-storybook/.storybook/main.ts index 516184f57..1291cd1c1 100644 --- a/apps/element-storybook/.storybook/main.ts +++ b/apps/element-storybook/.storybook/main.ts @@ -57,7 +57,7 @@ const config: StorybookConfig = { managerHead: (head) => ` ${head} - + `, viteFinal: async (config) => { From 9b56b8acebcfcee2fedfaf33b65c3fbcdde8fa7d Mon Sep 17 00:00:00 2001 From: Greg Martin Date: Thu, 6 Nov 2025 11:15:09 -0500 Subject: [PATCH 6/8] fix: storybook_base_path in storybook config --- apps/element-storybook/.storybook/main.ts | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/apps/element-storybook/.storybook/main.ts b/apps/element-storybook/.storybook/main.ts index 1291cd1c1..b45c09d2f 100644 --- a/apps/element-storybook/.storybook/main.ts +++ b/apps/element-storybook/.storybook/main.ts @@ -55,17 +55,9 @@ const config: StorybookConfig = { docs: {}, - managerHead: (head) => ` - ${head} - - `, - - viteFinal: async (config) => { - if (process.env.STORYBOOK_BASE_PATH) { - config.base = process.env.STORYBOOK_BASE_PATH + '/'; - } - return config; - } + ...(process.env.STORYBOOK_BASE_PATH && { + base: process.env.STORYBOOK_BASE_PATH + '/' + }) }; export default config; From 689ab67dc526fdb03385d53ad90dbdb639963657 Mon Sep 17 00:00:00 2001 From: Greg Martin Date: Thu, 6 Nov 2025 11:27:41 -0500 Subject: [PATCH 7/8] fix: simplify storybook config --- .github/workflows/preview.yml | 3 +-- apps/element-storybook/.storybook/main.ts | 6 +----- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 0856a1d6a..ef23db771 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -55,8 +55,6 @@ jobs: - name: Build Docs run: yarn build:storybook:ci - env: - STORYBOOK_BASE_PATH: /pr-preview/pr-${{ github.event.number }} - name: Deploy PR Preview uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0 @@ -65,6 +63,7 @@ jobs: publish_dir: dist/storybook destination_dir: pr-preview/pr-${{ github.event.number }} keep_files: true + enable_jekyll: false - name: Comment PR uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0 diff --git a/apps/element-storybook/.storybook/main.ts b/apps/element-storybook/.storybook/main.ts index b45c09d2f..c134ea2dc 100644 --- a/apps/element-storybook/.storybook/main.ts +++ b/apps/element-storybook/.storybook/main.ts @@ -53,11 +53,7 @@ const config: StorybookConfig = { storyStoreV7: false }, - docs: {}, - - ...(process.env.STORYBOOK_BASE_PATH && { - base: process.env.STORYBOOK_BASE_PATH + '/' - }) + docs: {} }; export default config; From ef01a608f217b7247367b459c0726424442e36ff Mon Sep 17 00:00:00 2001 From: Greg Martin Date: Thu, 6 Nov 2025 13:27:57 -0500 Subject: [PATCH 8/8] refactor: revert back to deploying from a branch --- .github/workflows/deploy.yml | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index e0a3a7c87..ed58d29d7 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -145,11 +145,7 @@ jobs: needs: [publish] runs-on: ubuntu-latest permissions: - pages: write - id-token: write - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} + contents: write steps: - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 with: @@ -172,11 +168,10 @@ jobs: - name: Build Docs run: yarn build:storybook:ci - - name: Upload Pages Artifact - uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3.0.1 - with: - path: dist/storybook - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5 + uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: dist/storybook + keep_files: true + enable_jekyll: false