Skip to content

Commit

Permalink
Added new CI/CD storybook actions
Browse files Browse the repository at this point in the history
  • Loading branch information
miksrv committed Oct 2, 2024
1 parent fd974a7 commit 7817240
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 4 deletions.
50 changes: 47 additions & 3 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on:
pull_request:
branches:
- main
push:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
Expand Down Expand Up @@ -63,7 +66,48 @@ jobs:

- if: ${{ steps.cache-build.outputs.cache-hit != 'true' }}
name: Build UI
run: yarn build

storybook-check:
name: Verify Storybook
runs-on: ubuntu-latest
needs: ui-checks

steps:
- uses: actions/checkout@v4

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'

- name: Cache node modules
uses: actions/cache@v4
id: cache-npm-storybook
with:
path: |
node_modules
~/.npm
key: ${{ runner.os }}-storybook-modules-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-storybook-modules-
${{ runner.os }}-
- if: ${{ steps.cache-npm-storybook.outputs.cache-hit != 'true' }}
name: Install dependencies for Storybook
working-directory: storybook
run: npm install

- name: Build Storybook
working-directory: storybook
run: npm run build-storybook

- name: Verify Storybook Build
run: |
export dateNow=$(date +"%Y-%m-%dT%H:%M")
echo "export const update = '$dateNow'" > update.ts
yarn build
if [ ! -d "storybook/storybook-static" ]; then
echo "Storybook build failed: directory not found."
exit 1
else
echo "Storybook build successful."
fi
36 changes: 36 additions & 0 deletions .github/workflows/storybook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Deploy Storybook

on:
pull_request:
branches:
- main
# paths:
# - 'storybook/**'

jobs:
build-storybook:
runs-on: ubuntu-latest
name: Build and Deploy Storybook

steps:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'

- name: Install dependencies for Storybook
working-directory: storybook
run: npm install

- name: Build Storybook
working-directory: storybook
run: npm run build-storybook

- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: storybook/storybook-static
1 change: 0 additions & 1 deletion storybook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"version": "1.0.0",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build"
},
Expand Down

0 comments on commit 7817240

Please sign in to comment.