-
Notifications
You must be signed in to change notification settings - Fork 673
143 lines (125 loc) · 4.39 KB
/
Copy pathpr-storybook-deploy-manual.yml
File metadata and controls
143 lines (125 loc) · 4.39 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
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: Lookup nx cache
id: lookup-nx-cache
uses: actions/cache/restore@v5
with:
path: |
.nx/cache
.nx/workspace-data/*.db
.nx/workspace-data/*.db-wal
.nx/workspace-data/*.db-shm
key: ${{ runner.os }}-nx-v2-${{ github.workflow }}-${{ github.job }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-nx-v2-${{ github.workflow }}-${{ github.job }}-${{ github.sha }}-
${{ runner.os }}-nx-v2-${{ github.workflow }}-${{ github.job }}-
${{ runner.os }}-nx-v2-
lookup-only: true
- name: Show nx cache status
shell: bash
run: |
echo "Nx cache lookup exact hit: ${{ steps.lookup-nx-cache.outputs.cache-hit }}"
echo "Nx cache primary key: ${{ steps.lookup-nx-cache.outputs.cache-primary-key }}"
echo "Nx cache matched key: ${{ steps.lookup-nx-cache.outputs.cache-matched-key }}"
if [ -z "${{ steps.lookup-nx-cache.outputs.cache-matched-key }}" ]; then
echo "Nx cache lookup: miss"
elif [ "${{ steps.lookup-nx-cache.outputs.cache-hit }}" = "true" ]; then
echo "Nx cache lookup: exact hit"
else
echo "Nx cache lookup: partial hit via restore-keys"
fi
- name: Install dependencies
if: inputs.action == 'deploy'
run: pnpm install --frozen-lockfile
- name: Setup nx cache
id: setup-nx-cache
uses: actions/cache@v5
with:
path: |
.nx/cache
.nx/workspace-data/*.db
.nx/workspace-data/*.db-wal
.nx/workspace-data/*.db-shm
key: ${{ runner.os }}-nx-v2-${{ github.workflow }}-${{ github.job }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-nx-v2-${{ github.workflow }}-${{ github.job }}-${{ github.sha }}-
${{ runner.os }}-nx-v2-${{ github.workflow }}-${{ github.job }}-
${{ runner.os }}-nx-v2-
- 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