Closed patcon closed 1 month ago
This might require some silliness and edge cases when adding new packages in a PR, because they might be missing if that packages are only pulled in from package-lock.json in mainline. To make this work, packages may need to be added to mainline for work happening on branches.
Alternatively, we could gradefully exit the storybook build for branches where diffs exist between the package-lock.json in mainline and a PR branch
Yay, working (ish)
First branch deploy is #7 at https://civictechto.github.io/polis-storybook/PR-7/
Automation runs on each push to mainline and to PRs.
Took a bit to figure this out, as it's a little messy (with submodules and checking out branches based on remote branch hashes on github), but this is now working fine!
Will likely have some funny edge-cases for git submodules when the commits update between branches, but works really well for now!
In future, might also want to consider using the pull_request_target
workflow trigger instead of the default pull_request
This is done now, as far as I can tell 🎉
We can use this branch-switcher addon for storybook to allow the single storybook site to switch between code from different branches/PRs: https://github.com/utarwyn/storybook-branch-switcher
It can have each PR generate a build of storybook for its branch: https://github.com/utarwyn/storybook-branch-switcher?tab=readme-ov-file#with-github-opened-prs
Unlike traditional PR flows, it's not deployable a new app for PRs, but instead pushing to the github pages main site (usually only deployed from
main
branch) for every commit to both mainline and pull request branches.To Dos
npm install
as part of branch build, to ensure pkgs even when package.json differsmain
branch isn't building/deploying properly for PRs (seems to get stripped envvar, which is used in addon to pass state around. maybe a github actions security feature?)PR-7
, also get mangled intohttps://civictechto.github.io/polis-storybookPR-7/polis-storybook/?path=/docs/overview--docs
instead ofhttps://civictechto.github.io/polis-storybook/PR-7/?path=/docs/overview--docs
pull_request_target
trigger 9a3a26chttps://github.com/marketplace/actions/comment-pull-request