Skip to content

Commit

Permalink
add build-storybook job into CI
Browse files Browse the repository at this point in the history
  • Loading branch information
shota-kamezawa committed Jun 13, 2023
1 parent fc3b471 commit 04f8207
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 0 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/_build-storybook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Build Storybook

on:
workflow_call:
inputs:
node-env:
description: NODE_ENV
required: false
type: string
default: development
use-artifact:
description: Upload built artifact if true
required: true
type: boolean
outputs:
artifact-name:
description: For 'name' of actions/download-articaft
value: ${{ jobs.build.outputs.artifact-name }}
artifact-path:
description: For 'path' of actions/download-articaft
value: ${{ jobs.build.outputs.artifact-path }}

env:
ARTIFACT_PATH: storybook-static
NODE_ENV: ${{ inputs.node-env }}

jobs:
install-dependencies:
needs: []
uses: ./.github/workflows/_install-dependencies.yml
with:
node-env: ${{ inputs.node-env }}

build:
needs: [install-dependencies]
runs-on: ubuntu-latest
outputs:
artifact-name: ${{ steps.artifact-name.outputs.VALUE }}
artifact-path: ${{ steps.artifact-path.outputs.VALUE }}
steps:
- uses: actions/checkout@v3

- id: setup-node
uses: actions/setup-node@v3
with:
node-version: ${{ needs.install-dependencies.outputs.node-version }}

- uses: actions/cache/restore@v3
with:
key: ${{ needs.install-dependencies.outputs.node-modules-cache-key }}
path: ${{ needs.install-dependencies.outputs.node-modules-cache-path }}

- run: yarn run postinstall
shell: bash

- run: yarn run storybook:build
shell: bash

- id: artifact-name
run: echo "VALUE=build-${GITHUB_SHA}" >> $GITHUB_OUTPUT
shell: bash

- id: artifact-path
run: echo "VALUE=${ARTIFACT_PATH}" >> $GITHUB_OUTPUT
shell: bash

- if: ${{ inputs.use-artifact == true }}
uses: actions/upload-artifact@v3
with:
name: ${{ steps.artifact-name.outputs.VALUE }}
path: ${{ steps.artifact-path.outputs.VALUE }}
retention-days: 5
19 changes: 19 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,25 @@ jobs:
- run: yarn run coverage
shell: bash

build-storybook:
needs: [install-dependencies]
uses: ./.github/workflows/_build-storybook.yml
with:
use-artifact: true

check-built-storybook:
needs: [build-storybook]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v3
with:
name: ${{ needs.build-storybook.outputs.artifact-name }}
path: ${{ needs.build-storybook.outputs.artifact-path }}

- run: ls -a
shell: bash
working-directory: ${{ needs.build-storybook.outputs.artifact-path }}

build-app:
needs: []
uses: ./.github/workflows/_build-app.yml
Expand Down

0 comments on commit 04f8207

Please sign in to comment.