From 31d52af8d5a8d97c8eef2955d8c6df5a4736cfaf Mon Sep 17 00:00:00 2001
From: william dutton <will.dutt@gmail.com>
Date: Fri, 29 Mar 2024 13:15:09 +1000
Subject: [PATCH] Use github actions for pages deployment

---
 .github/workflows/storybook-deploy.js.yml | 42 +++++++++++++++++------
 1 file changed, 32 insertions(+), 10 deletions(-)

diff --git a/.github/workflows/storybook-deploy.js.yml b/.github/workflows/storybook-deploy.js.yml
index 00e1eb65..fcc5bc44 100644
--- a/.github/workflows/storybook-deploy.js.yml
+++ b/.github/workflows/storybook-deploy.js.yml
@@ -1,24 +1,35 @@
 name: Storybook deploy
 
 on:
+  # Allows you to run this workflow manually from the Actions tab
+  workflow_dispatch:
   workflow_run:
     workflows: [Build and Test] # Reuse the name of your tests workflow
     branches: [main, develop]
     types: [completed ]
 
+# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
+permissions:
+  contents: read
+  pages: write
+  actions: read
+  id-token: write
+
 concurrency:
   group: deploy-${{ github.workflow }}-${{ github.ref }} # Recommended if you intend to make multiple deployments in quick succession.
-  cancel-in-progress: true
+  cancel-in-progress: false
 
 jobs:
   deploy:
-
+    environment:
+      name: github-pages
+      url: ${{ steps.deployment.outputs.page_url }}
     runs-on: ubuntu-latest
     strategy:
       matrix:
         node: [ '20' ]
     name: Deploy with Node ${{ matrix.node }}
-    if: ${{ github.event.workflow_run.conclusion == 'success' }}
+    if: ${{ github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' }}
     steps:
       - uses: actions/checkout@v4
 
@@ -69,11 +80,22 @@ jobs:
         with:
           name: Storybook
           path: storybook-static
-      - name: Deploy 🚀
-        uses: JamesIves/github-pages-deploy-action@v4
+
+      - name: Setup Pages
+        uses: actions/configure-pages@v4
+      - name: Upload artifact
+        uses: actions/upload-pages-artifact@v3
         with:
-          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-          BRANCH: gh-pages # The branch the action should deploy to.
-          FOLDER: storybook-static # The folder that the build-storybook script generates files.
-          CLEAN: true # Automatically remove deleted files from the deploy branch
-          TARGET_FOLDER: docs # The folder that we serve our Storybook files from
+          path: "./storybook-static"
+      - name: Deploy to GitHub Pages
+        id: deployment
+        uses: actions/deploy-pages@v4.0.5
+
+#      - name: Deploy 🚀 #to branch for old website deployment
+#        uses: JamesIves/github-pages-deploy-action@v4
+#        with:
+#          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+#          BRANCH: gh-pages # The branch the action should deploy to.
+#          FOLDER: storybook-static # The folder that the build-storybook script generates files.
+#          CLEAN: true # Automatically remove deleted files from the deploy branch
+#          TARGET_FOLDER: docs # The folder that we serve our Storybook files from