-
Notifications
You must be signed in to change notification settings - Fork 1
95 lines (81 loc) · 2.94 KB
/
storybook-update.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
# storybook update
name: storybook-update
on: workflow_dispatch
env:
DATABASE_URL: postgresql://test:test@localhost:5432/test?schema=public
jobs:
storybook-update:
timeout-minutes: 10
runs-on: ubuntu-latest
permissions:
contents: write
services:
postgres:
image: postgres:latest
env:
POSTGRES_USER: test
POSTGRES_PASSWORD: test
POSTGRES_DB: test
ports:
- 5432:5432
steps:
- name: checkout git repository
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
- name: cache frontend node-modules
id: cache-frontend-node-modules
uses: actions/cache@v3
with:
path: frontend/node_modules
key: cache-frontend-node-modules-${{ hashFiles('frontend/package-lock.json') }}
- name: playwright version
run: npx playwright -V > playwright-version.txt && cat playwright-version.txt
- name: cache playwright
id: cache-playwright
uses: actions/cache@v3
with:
path: ~/.cache/ms-playwright
key: cache-playwright-${{ hashFiles('frontend/package-lock.json') }}-${{ hashFiles('playwright-version.txt') }}
- name: cache backend node-modules
id: cache-backend-node-modules
uses: actions/cache@v3
with:
path: backend/node_modules
key: cache-backend-node-modules-${{ hashFiles('backend/package-lock.json') }}
- name: setup backend
run: |
cd backend
make setup
make setup-db
npm run start:dev &
- name: setup frontend
run: |
cd frontend
make setup
- if: ${{ steps.cache-playwright.outputs.cache-hit != 'true' }}
name: install playwright
run: cd frontend && npx playwright install
- name: install playwright deps & storybook build
run: |
cd frontend
npx playwright install-deps &
npx_playwright_install_deps_pid=$(echo $!)
npm run storybook-build
echo wait ${npx_playwright_install_deps_pid}
wait ${npx_playwright_install_deps_pid}
python3 -m http.server 6006 --directory storybook-static &
timeout 30 bash -c 'while ! >/dev/tcp/localhost/6006; do sleep 3; done'
- name: is storybook file exists
run: cd frontend && make sb-ck-file
- name: rm img files
run: rm -rf $(find frontend/src/ -type d -name '__image_snapshots__')
- name: run storybook update
run: cd frontend && npm run storybook-update-snapshot
# 変更がない時は、commit 失敗して終了
- name: git commit
run: |
git config user.name s-github-action
git config user.email ${{ secrets.GIT_EMAIL }}
git add $(find frontend/src -name '*.png')
(git commit -m '[auto commit from github action] sb-update' && git push) || echo commit or push fail