Repository navigation
130 lines (122 loc) · 4.11 KB
/
Copy pathdeploy-github-pages.yml
File metadata and controls
130 lines (122 loc) · 4.11 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
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
- uses: actions/setup-node@v4
with:
node-version: "lts/*"
- 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}]"
# Last-commit date per branch (Europe/Tallinn) for the In-development cards.
git -C .. fetch origin --no-tags --quiet '+refs/heads/*:refs/remotes/origin/*' || true
branch_updated="{}"
for b in $(echo "$valid_branches" | jq -r '.[]'); do
d=$(TZ=Europe/Tallinn git -C .. log -1 --format=%cd --date=format-local:'%d.%m.%Y %H:%M' "origin/$b" 2>/dev/null || echo "")
branch_updated=$(echo "$branch_updated" | jq -c --arg k "$b" --arg v "$d" '. + {($k): $v}')
done
# Inject the data object the page renders: framework + main/rc versions &
# publish timestamps (from npm) + the valid branch list + per-branch commit dates.
# Change "Angular" and the package name in the React repo; index.html stays identical.
node ../.github/workflows/pages-release-info.mjs "Angular" "@tedi-design-system/angular" \
| jq -c --argjson branches "$valid_branches" --argjson updated "$branch_updated" \
'. + {branches: $branches, branchUpdated: $updated}' \
>> 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