-
Notifications
You must be signed in to change notification settings - Fork 19
63 lines (48 loc) · 1.83 KB
/
publish-prod-storybook.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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