-
Notifications
You must be signed in to change notification settings - Fork 14
122 lines (104 loc) · 3.37 KB
/
Copy pathdeploy-storybook.yml
File metadata and controls
122 lines (104 loc) · 3.37 KB
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
name: Deploy Storybook
on:
workflow_dispatch:
push:
branches:
- main
paths:
- 'examples/storybook/**'
- 'packages/**'
- 'pnpm-lock.yaml'
- 'pnpm-workspace.yaml'
pull_request_target:
types: [opened, synchronize, edited, ready_for_review]
branches:
- main
paths:
- 'examples/storybook/**'
- 'packages/**'
- 'pnpm-lock.yaml'
- 'pnpm-workspace.yaml'
concurrency:
group: deploy-storybook-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
jobs:
# Fork PRs wait on the `external` environment, where maintainers configure
# required reviewers. Internal PRs continue directly to their preview.
authorize-preview:
if: github.event_name == 'pull_request_target'
runs-on: ubuntu-latest
environment: ${{ github.event.pull_request.head.repo.full_name != github.repository && 'external' || 'internal' }}
steps:
- run: true
preview:
if: github.event_name == 'pull_request_target'
needs: authorize-preview
runs-on: ubuntu-latest
environment:
name: preview
url: ${{ steps.deploy.outputs.url }}
defaults:
run:
working-directory: examples/storybook
steps:
- name: Checkout pull request head
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9.15.0
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
working-directory: ${{ github.workspace }}
- name: Pull Vercel project settings
run: pnpm exec vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
- name: Build Storybook preview
run: pnpm exec vercel build --token=${{ secrets.VERCEL_TOKEN }}
- name: Deploy preview
id: deploy
run: |
url="$(pnpm exec vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }})"
echo "url=$url" >> "$GITHUB_OUTPUT"
production:
if: github.event_name != 'pull_request_target'
runs-on: ubuntu-latest
environment:
name: production
url: ${{ steps.deploy.outputs.url }}
defaults:
run:
working-directory: examples/storybook
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9.15.0
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
working-directory: ${{ github.workspace }}
- name: Pull Vercel project settings
run: pnpm exec vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
- name: Build Storybook deployment
run: pnpm exec vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
- name: Deploy production
id: deploy
run: |
url="$(pnpm exec vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }})"
echo "url=$url" >> "$GITHUB_OUTPUT"