-
Notifications
You must be signed in to change notification settings - Fork 1
105 lines (99 loc) · 2.79 KB
/
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# https://github.com/orgs/community/discussions/21582
name: Build and Publish Storybook to GitHub Pages
on:
# Event for the workflow to run on
push:
branches:
- '**' # Run on all branches
permissions:
contents: write
pages: write
id-token: write
actions: read
concurrency:
group: "pages"
cancel-in-progress: true
# List of jobs
jobs:
build_matrix:
runs-on: ubuntu-latest
outputs:
json_branches: ${{ steps.generate-matrix.outputs.json_branches }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate Matrix
id: generate-matrix
run: |
branches=($(git branch -r | cut -c 3- | sed 's/origin\///g'))
json_branches=$(printf '%s\n' "${branches[@]}" | jq -R . | jq -s -c .)
echo "json_branches=${json_branches}" >> $GITHUB_OUTPUT
build:
runs-on: ubuntu-latest
name: Build
env:
HUSKY: 0
needs:
- build_matrix
strategy:
matrix:
branch: ${{ fromJSON(needs.build_matrix.outputs.json_branches) }}
continue-on-error: true
steps:
- uses: actions/checkout@v4
with:
ref: ${{ matrix.branch }}
- uses: actions/setup-node@v4
with:
node-version: 'lts/*'
- name: Install dependencies
run: npm ci
- name: Build Storybook
run: npm run build-storybook
- name: Sanitize branch name
id: sanitize
run: echo "SANITIZED_BRANCH=$(echo ${{ matrix.branch }} | sed 's/\//-/g')" >> $GITHUB_ENV
- uses: actions/upload-artifact@v3
with:
name: ${{ env.SANITIZED_BRANCH }}
path: storybook-static/
deploy:
runs-on: ubuntu-latest
name: Deploy
env:
HUSKY: 0
if: always()
needs:
- build_matrix
- build
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Clean public folder
run: rm -rf public/*
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: ${{ env.SANITIZED_BRANCH }}
path: public/
- name: Generate overview.html
run: |
echo "<html><body><h1>Storybook Versions</h1><ul>" > public/overview.html
for dir in $(ls public); do
echo "<li><a href=\"$dir\">$dir</a></li>" >> public/overview.html
done
echo "</ul></body></html>" >> public/overview.html
- name: Move content from /public/main to public
run: |
rsync -a public/main/ public/
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./public/
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4