Skip to content

Commit

Permalink
Build and Upload Storybook in Github Workflows
Browse files Browse the repository at this point in the history
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
  • Loading branch information
meisekimiu committed Dec 12, 2024
1 parent b151f0a commit 7916e6c
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 3 deletions.
37 changes: 36 additions & 1 deletion .github/workflows/build-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
36 changes: 35 additions & 1 deletion .github/workflows/build-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -66,19 +94,25 @@ 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
uses: actions/download-artifact@v4
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
Expand Down
35 changes: 34 additions & 1 deletion .github/workflows/build-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -66,19 +93,25 @@ 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
uses: actions/download-artifact@v4
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
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
/dist
/tmp
/out-tsc
/storybook-static

# dependencies
/node_modules
Expand Down

0 comments on commit 7916e6c

Please sign in to comment.