Skip to content

Commit 3534be7

Browse files
Ruslan FarkhutdinovRuslan Farkhutdinov
andauthored
Storybook: Add manual deployment workflow (#32356)
Co-authored-by: Ruslan Farkhutdinov <ruslan.farkhutdinov@devexpress.com>
1 parent a7767ce commit 3534be7

1 file changed

Lines changed: 92 additions & 0 deletions

File tree

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: Storybook PR Preview (manual)
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
pr_number:
7+
description: "Pull Request number"
8+
required: true
9+
type: string
10+
action:
11+
description: "What to do with the preview"
12+
required: true
13+
type: choice
14+
options:
15+
- deploy
16+
- remove
17+
default: deploy
18+
19+
permissions:
20+
contents: write
21+
pull-requests: write
22+
23+
concurrency:
24+
group: storybook-preview-${{ inputs.pr_number }}
25+
cancel-in-progress: true
26+
27+
env:
28+
SOURCE_DIR: ./apps/react-storybook/storybook-static
29+
30+
jobs:
31+
preview:
32+
name: ${{ inputs.action }} Storybook preview for PR
33+
runs-on: ubuntu-latest
34+
timeout-minutes: 30
35+
environment: github-pages
36+
37+
steps:
38+
- name: Checkout PR head commit
39+
if: inputs.action == 'deploy'
40+
uses: actions/checkout@v4
41+
with:
42+
ref: refs/pull/${{ inputs.pr_number }}/head
43+
fetch-depth: 1
44+
45+
- name: Use Node.js
46+
if: inputs.action == 'deploy'
47+
uses: actions/setup-node@v4
48+
with:
49+
node-version: "20"
50+
51+
- name: Setup pnpm
52+
if: inputs.action == 'deploy'
53+
uses: pnpm/action-setup@v4
54+
with:
55+
run_install: false
56+
57+
- name: Get pnpm store directory
58+
if: inputs.action == 'deploy'
59+
shell: bash
60+
run: |
61+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
62+
63+
- name: Setup pnpm + nx cache
64+
if: inputs.action == 'deploy'
65+
uses: actions/cache@v4
66+
with:
67+
path: |
68+
${{ env.STORE_PATH }}
69+
.nx/cache
70+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
71+
restore-keys: |
72+
${{ runner.os }}-pnpm-store
73+
74+
- name: Install dependencies
75+
if: inputs.action == 'deploy'
76+
run: pnpm install --frozen-lockfile
77+
78+
- name: Build Storybook preview (static)
79+
if: inputs.action == 'deploy'
80+
run: |
81+
pnpx nx build devextreme-react-storybook
82+
83+
- name: Deploy/remove PR preview
84+
uses: rossjrw/pr-preview-action@8ff09e486b4c23709012eedd3b42e9f0b95dd0c5 # v1
85+
with:
86+
action: ${{ inputs.action }}
87+
pr-number: ${{ inputs.pr_number }}
88+
source-dir: ${{ env.SOURCE_DIR }}
89+
preview-branch: gh-pages
90+
umbrella-dir: preview
91+
comment: false
92+
token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)