Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build and Upload Storybook in Github Workflows #504

Merged
merged 1 commit into from
Dec 12, 2024
Merged

Conversation

meisekimiu
Copy link
Member

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.

Steps to test:

  1. Run a build of this branch and deploy it to a test environment (the deploy is done automatically on dev)
  2. After the deployment is done, ssh into the backend box for the environment and check that /data/www/mdot contains a storybook directory alongside its usual dist directory.
  3. Check that the storybook directory has built HTML/JavaScript files in it.

This does not need any QA.

@meisekimiu meisekimiu requested review from slifty and liam-lloyd and removed request for slifty December 11, 2024 16:53
Copy link

codecov bot commented Dec 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 43.21%. Comparing base (b151f0a) to head (7916e6c).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #504      +/-   ##
==========================================
- Coverage   43.22%   43.21%   -0.01%     
==========================================
  Files         363      363              
  Lines       11102    11102              
  Branches     1809     1809              
==========================================
- Hits         4799     4798       -1     
- Misses       6141     6142       +1     
  Partials      162      162              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines +45 to +72
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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd recommend factoring this (and the build job) into their own files and invoking them from each of the deploy actions via

jobs:
  build:
    uses: ./.github/workflows/build.yml

It looks to me like the artifact upload/download will just continue to work in that case, though I haven't tested this myself.

Copy link
Member

@liam-lloyd liam-lloyd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed that this does work, and I think it's up to you whether you want to factor out the build jobs here or leave that for the potholes sprint.

@meisekimiu
Copy link
Member Author

I'll merge this now and refactor it during the Potholes sprint since it seems a bit involved (and multiple open PRs have edits to the workflows right now and I'd prefer to merge these changes as soon as possible)

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
@meisekimiu meisekimiu merged commit 806f579 into main Dec 12, 2024
4 checks passed
@meisekimiu meisekimiu deleted the build-storybook branch December 12, 2024 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants