Skip to content

PR Storybook - Preview (manual) #50

PR Storybook - Preview (manual)

PR Storybook - Preview (manual) #50

name: PR Storybook - Preview (manual)
on:
workflow_dispatch:
inputs:
pr_number:
description: "Pull Request number"
required: true
type: string
action:
description: "What to do with the preview"
required: true
type: choice
options:
- deploy
- remove
default: deploy
permissions:
contents: write
pull-requests: write
concurrency:
group: storybook-${{ inputs.pr_number }}
cancel-in-progress: true
env:
NX_SKIP_NX_CACHE: true
SOURCE_DIR: ./apps/react-storybook/storybook-static
jobs:
preview:
name: ${{ inputs.action }} Storybook preview for PR
runs-on: ubuntu-latest
timeout-minutes: 30
environment: storybook-manual
steps:
- name: Checkout PR head commit
if: inputs.action == 'deploy'
uses: actions/checkout@v6
with:
ref: refs/pull/${{ inputs.pr_number }}/head
fetch-depth: 1
- name: Checkout base repo
if: inputs.action == 'remove'
uses: actions/checkout@v6
with:
fetch-depth: 1
- name: Use Node.js
if: inputs.action == 'deploy'
uses: actions/setup-node@v6
with:
node-version-file: '.node-version'
- name: Setup pnpm
if: inputs.action == 'deploy'
uses: pnpm/action-setup@v6
with:
run_install: false
- name: Get pnpm store directory
if: inputs.action == 'deploy'
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Setup pnpm cache
if: inputs.action == 'deploy'
uses: actions/cache@v5
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-cache-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-cache
- name: Install dependencies
if: inputs.action == 'deploy'
run: pnpm install --frozen-lockfile
- name: Build Storybook preview (static)
if: inputs.action == 'deploy'
run: |
pnpm exec nx build devextreme-react-storybook
- name: Deploy/remove PR preview
uses: rossjrw/pr-preview-action@ffa7509e91a3ec8dfc2e5536c4d5c1acdf7a6de9 # v1.8.1
with:
action: ${{ inputs.action }}
pr-number: ${{ inputs.pr_number }}
source-dir: ${{ env.SOURCE_DIR }}
preview-branch: gh-pages
umbrella-dir: storybook
comment: false
wait-for-pages-deployment: true