-
Notifications
You must be signed in to change notification settings - Fork 41
139 lines (115 loc) · 4.32 KB
/
hds-demo-preview.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
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
131
132
133
134
135
136
137
138
139
name: hds-demo-preview
on:
pull_request:
branches:
- development
- release-*
- 'feature/*'
push:
branches:
- development
- release-*
- 'feature/*'
jobs:
build_and_publish_demo:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
env:
PATH_PREFIX: "/hds-demo/preview_${{ github.event.number != '' && github.event.number || github.ref_name }}"
DEMO_NAME: preview_${{ github.event.number != '' && github.event.number || github.ref_name }}
steps:
- name: Checkout code hds
uses: actions/checkout@v4
- name: Read .nvmrc
run: echo "NODE_VERSION=$(cat .nvmrc)" >> $GITHUB_OUTPUT
id: nvmrc
- name: setup node ${{ steps.nvmrc.outputs.NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: '${{ steps.nvmrc.outputs.NODE_VERSION }}'
registry-url: 'https://registry.npmjs.org'
# Github cache
- name: get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- name: restore yarn cache
uses: actions/cache@v4
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: yarn-cache-folder-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
yarn-cache-folder-
- name: restore lerna
uses: actions/cache@v4
with:
path: '**/node_modules'
key: yarn-node_modules-folder-${{ hashFiles('**/yarn.lock') }}
# Build
- name: install dependencies
run: |
yarn config set network-timeout 300000
yarn
# Build site
- name: build design tokens package
run: yarn build
working-directory: ./packages/design-tokens
- name: build core package
run: yarn build
working-directory: ./packages/core
- name: build react package
run: yarn build
working-directory: ./packages/react
- name: build hds-js package
run: yarn build:hds-js
working-directory: ./packages/react
- name: build site package
run: yarn build --prefix-paths
working-directory: ./site
# Build core storybook
- name: build core storybook
run: yarn build-storybook
working-directory: ./packages/core
- name: move core storybook under site
run: mkdir ./site/public/storybook && mv ./packages/core/storybook-static $_/core
# Build react storybook
- name: build react storybook
run: yarn build-storybook
working-directory: ./packages/react
- name: move react storybook under site
run: mv ./packages/react/storybook-static ./site/public/storybook/react
# Publish to hds-demo
- name: Checkout code hds-demo
uses: actions/checkout@v4
with:
repository: City-of-Helsinki/hds-demo
path: hds-demo
ssh-key: ${{ secrets.HDSDEMO_SSH_DEPLOY_KEY }}
- name: Clean old directory
run: |
rm -fr ./hds-demo/docs/$DEMO_NAME
mkdir -p ./hds-demo/docs/$DEMO_NAME
- name: Copy build results
run: cp -r ./site/public/* ./hds-demo/docs/$DEMO_NAME
- name: Commit
run: |
git config --global user.email "hds@hel.fi"
git config --global user.name "Github Actions"
git status
git add .
git commit -m "Updated preview to $DEMO_NAME"
git status
git pull --rebase
git push
working-directory: ./hds-demo
- name: Preview url to PR comment
if: github.event_name == 'pull_request'
uses: marocchino/sticky-pull-request-comment@v2
with:
header: Preview url
message: |
Preview found from [hds-demo docs/${{ env.DEMO_NAME }}](https://github.com/City-of-Helsinki/hds-demo/tree/main/docs/${{ env.DEMO_NAME }})
## Demos
[Docs](https://city-of-helsinki.github.io/hds-demo/${{ env.DEMO_NAME }})
[Core Storybook](https://city-of-helsinki.github.io/hds-demo/${{ env.DEMO_NAME }}/storybook/core)
[React Storybook](https://city-of-helsinki.github.io/hds-demo/${{ env.DEMO_NAME }}/storybook/react)