-
Notifications
You must be signed in to change notification settings - Fork 3
114 lines (106 loc) · 3 KB
/
deploy-github-pages.yml
File metadata and controls
114 lines (106 loc) · 3 KB
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
106
107
108
109
110
111
112
113
114
name: Continuous Deployment
on:
workflow_dispatch:
push:
branches:
- "**"
permissions:
contents: read
pages: write
id-token: write
actions: read
concurrency:
group: "pages"
cancel-in-progress: true
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: |
echo "$(.github/workflows/list-storybook-branches.sh)"
echo "json_branches=$(.github/workflows/list-storybook-branches.sh)" >> $GITHUB_OUTPUT
build:
runs-on: ubuntu-latest
name: Build
needs: build_matrix
strategy:
fail-fast: false
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 and Build Storybook
run: |
npm ci
npm run build:sb
mkdir -p compiled-storybook
mv dist/storybook-static/* compiled-storybook/
- uses: actions/upload-artifact@v4
with:
name: ${{ strategy.job-index }}
path: compiled-storybook/
deploy:
runs-on: ubuntu-latest
name: Deploy
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
needs:
- build_matrix
- build
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Pages
uses: actions/configure-pages@v4
- uses: actions/download-artifact@v4
name: "Download artifacts"
with:
path: branches/
- name: Create gpages folder
shell: bash
run: |
ls -la branches
mkdir gpages
mv .github/workflows/index.html ./gpages/index.html
cd gpages
branches=$(echo '${{ needs.build_matrix.outputs.json_branches }}' | jq -r '.[]')
valid_branches=""
i=-1
for branch in ${branches};
do
echo "Processing branch: $branch"
i=$((i+1))
if [[ -d ../branches/$i ]]; then
echo "Branch $branch deemed legit, adding to valid branches"
valid_branches+="\"$branch\","
mkdir -p -- $branch
mv ../branches/$i/* ./$branch
else
echo "Excluding $branch because folder does not exist"
fi
done
valid_branches="[${valid_branches::-1}]"
echo "$valid_branches" >> index.html
cat ../.github/workflows/index_suffix.html >> index.html
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./gpages/
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4