Merge pull request #449 from adobe/dependabot/npm_and_yarn/react-ec17… #332
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish Storybook to GitHub Pages | |
# This action runs when a branch has been merged to main. | |
on: | |
push: | |
branches: | |
- main | |
permissions: | |
pages: write | |
id-token: write | |
contents: write | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '18' | |
- name: Install Dependencies 📦 | |
run: yarn install | |
- name: Build Storybook | |
run: yarn build:storybook | |
- name: Checkout and clean current 'gh-pages' branch | |
run: | | |
git config user.name "evargast" | |
git config user.email "[email protected]" | |
# Fetch the existing gh-pages branch | |
git fetch origin gh-pages | |
# Checkout the existing gh-pages branch | |
git checkout gh-pages | |
# Remove all files | |
git rm -r --cached . | |
# Restore directories starting with "PR-" | |
find . -mindepth 1 -maxdepth 1 -type d -name 'PR-*' -exec git reset {} + | |
# Explicitly remove the node_modules directory | |
rm -rf node_modules | |
- name: Copy 'dist-storybook' to 'gh-pages' branch | |
run: | | |
cp -r dist-storybook/* . | |
- name: Commit and push changes to 'gh-pages' branch | |
run: | | |
git add -- . ':!dist-storybook' | |
git commit -m "Update gh-pages with latest Storybook build" | |
git push origin gh-pages |