From 7916e6c4b01aa6f343047cc0317eb15d9f9f83aa Mon Sep 17 00:00:00 2001 From: Natalie Martin Date: Wed, 11 Dec 2024 10:29:03 -0600 Subject: [PATCH] Build and Upload Storybook in Github Workflows To make Storybook easier to access for non-developers, we want to build a static version of it that gets deployed to each environment. This requires building a copy of Storybook alongside the main production build and then uploading that static Storybook directory as well. This is done by creating a new `build-storybook` step. Both Storybook and the main production build are uploaded in the `upload-code` step. Also update .gitignore to ignore the statically built Storybook directory. PER-9925: Build Storybook as part of web-app build process --- .github/workflows/build-dev.yml | 37 ++++++++++++++++++++++++++++- .github/workflows/build-prod.yml | 36 +++++++++++++++++++++++++++- .github/workflows/build-staging.yml | 35 ++++++++++++++++++++++++++- .gitignore | 1 + 4 files changed, 106 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-dev.yml b/.github/workflows/build-dev.yml index fa782c452..3f6abef1b 100644 --- a/.github/workflows/build-dev.yml +++ b/.github/workflows/build-dev.yml @@ -42,6 +42,34 @@ jobs: name: dist path: dist + build-storybook: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: "18" + + - uses: actions/cache@v4 + with: + path: node_modules + key: ${{ runner.os }}-node_modules-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node_modules- + + - name: Install dependencies + run: npm install + + - name: Build Storybook + run: npm run build-storybook + + - name: Archive `storybook-static` + uses: actions/upload-artifact@v4 + with: + name: storybook + path: storybook-static + upload-sourcemaps: needs: build runs-on: ubuntu-latest @@ -74,7 +102,7 @@ jobs: sentry-cli releases files $VERSION upload-sourcemaps --validate --log-level info --strip-common-prefix ./dist/ --ignore mdot upload-code: - needs: build + needs: [build, build-storybook] runs-on: ubuntu-latest steps: - name: Download dist @@ -83,11 +111,18 @@ jobs: name: dist path: dist + - name: Download storybook + uses: actions/download-artifact@v4 + with: + name: storybook + path: storybook + - name: Create a tar archive run: | cd .. mkdir mdot mv web-app/dist mdot/dist + mv web-app/storybook mdot/storybook tar -czvf mdot.tar.gz mdot - name: Configure AWS Credentials diff --git a/.github/workflows/build-prod.yml b/.github/workflows/build-prod.yml index 521805694..30d073acd 100644 --- a/.github/workflows/build-prod.yml +++ b/.github/workflows/build-prod.yml @@ -36,6 +36,34 @@ jobs: with: name: dist path: dist + + build-storybook: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: "18" + + - uses: actions/cache@v4 + with: + path: node_modules + key: ${{ runner.os }}-node_modules-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node_modules- + + - name: Install dependencies + run: npm install + + - name: Build Storybook + run: npm run build-storybook + + - name: Archive `storybook-static` + uses: actions/upload-artifact@v4 + with: + name: storybook + path: storybook-static upload-sourcemaps: needs: build @@ -66,7 +94,7 @@ jobs: sentry-cli releases files $VERSION upload-sourcemaps --validate --log-level info --strip-common-prefix ./dist/ --ignore mdot upload-code: - needs: build + needs: [build, build-storybook] runs-on: ubuntu-latest steps: - name: Download dist @@ -74,11 +102,17 @@ jobs: with: name: dist path: dist + - name: Download storybook + uses: actions/download-artifact@v4 + with: + name: storybook + path: storybook - name: Create a tar archive run: | cd .. mkdir mdot mv web-app/dist mdot/dist + mv web-app/storybook mdot/storybook tar -czvf mdot.tar.gz mdot - name: Configure AWS Credentials uses: aws-actions/configure-aws-credentials@v4 diff --git a/.github/workflows/build-staging.yml b/.github/workflows/build-staging.yml index f63c28d98..426d0cc3f 100644 --- a/.github/workflows/build-staging.yml +++ b/.github/workflows/build-staging.yml @@ -36,6 +36,33 @@ jobs: with: name: dist path: dist + build-storybook: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: "18" + + - uses: actions/cache@v4 + with: + path: node_modules + key: ${{ runner.os }}-node_modules-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node_modules- + + - name: Install dependencies + run: npm install + + - name: Build Storybook + run: npm run build-storybook + + - name: Archive `storybook-static` + uses: actions/upload-artifact@v4 + with: + name: storybook + path: storybook-static upload-sourcemaps: needs: build @@ -66,7 +93,7 @@ jobs: sentry-cli releases files $VERSION upload-sourcemaps --validate --log-level info --strip-common-prefix ./dist/ --ignore mdot upload-code: - needs: build + needs: [build, build-storybook] runs-on: ubuntu-latest steps: - name: Download dist @@ -74,11 +101,17 @@ jobs: with: name: dist path: dist + - name: Download storybook + uses: actions/download-artifact@v4 + with: + name: storybook + path: storybook - name: Create a tar archive run: | cd .. mkdir mdot mv web-app/dist mdot/dist + mv web-app/storybook mdot/storybook tar -czvf mdot.tar.gz mdot - name: Configure AWS Credentials uses: aws-actions/configure-aws-credentials@v4 diff --git a/.gitignore b/.gitignore index f86a705b5..07a347cca 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ /dist /tmp /out-tsc +/storybook-static # dependencies /node_modules