Skip to content

Commit 271835f

Browse files
committed
Some GHA changes to allow deploying storybook separately
Also: - fixes storybook deployment - fixes bad public path for fonts
1 parent 5f4c49f commit 271835f

File tree

8 files changed

+126
-82
lines changed

8 files changed

+126
-82
lines changed

.github/actions/setup/action.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: 'Setup Workspace'
2+
description: 'Checkout code, setup Node.js with pnpm, and install dependencies'
3+
4+
inputs:
5+
npm-token:
6+
description: 'NPM token for authentication'
7+
required: false
8+
9+
runs:
10+
using: 'composite'
11+
steps:
12+
- uses: actions/checkout@v4
13+
with:
14+
fetch-depth: 0
15+
persist-credentials: false
16+
17+
- uses: pnpm/action-setup@v4
18+
19+
- uses: actions/setup-node@v4
20+
env:
21+
NODE_AUTH_TOKEN: ${{ inputs.npm-token }}
22+
with:
23+
node-version-file: package.json
24+
cache: "pnpm"
25+
always-auth: "true"
26+
scope: "@plextv"
27+
registry-url: "https://registry.npmjs.org"
28+
29+
- name: Install dependencies
30+
run: pnpm install --frozen-lockfile
31+
shell: bash
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Deploy Storybook
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
9+
concurrency: ${{ github.workflow }}-${{ github.ref }}
10+
11+
permissions:
12+
pages: write # to deploy to Pages
13+
id-token: write
14+
15+
jobs:
16+
build-and-deploy:
17+
name: Build and Deploy Storybook
18+
runs-on: ubuntu-latest
19+
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
20+
21+
environment:
22+
name: github-pages
23+
url: ${{ steps.deployment.outputs.page_url }}
24+
25+
steps:
26+
- name: Setup workspace
27+
uses: plexinc/react-lightning/.github/actions/setup@main
28+
with:
29+
npm-token: ${{ secrets.NPM_TOKEN }}
30+
31+
- name: Build Storybook
32+
run: pnpm run build:storybook
33+
34+
- name: Upload storybook static files as artifact
35+
uses: actions/upload-pages-artifact@v3
36+
with:
37+
path: apps/storybook/dist/
38+
39+
- name: Deploy to GitHub Pages
40+
id: deployment
41+
uses: actions/deploy-pages@v4
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Release Packages
2+
3+
on:
4+
workflow_dispatch:
5+
workflow_run:
6+
workflows: ["Run tests"]
7+
branches: [main]
8+
types:
9+
- completed
10+
11+
concurrency: ${{ github.workflow }}-${{ github.ref }}
12+
13+
permissions:
14+
id-token: write
15+
16+
jobs:
17+
release:
18+
name: Release Packages
19+
runs-on: ubuntu-latest
20+
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }}
21+
22+
outputs:
23+
published: ${{ steps.changesets.outputs.published }}
24+
25+
steps:
26+
- name: Setup workspace
27+
uses: plexinc/react-lightning/.github/actions/setup@main
28+
with:
29+
npm-token: ${{ secrets.NPM_TOKEN }}
30+
31+
- name: Create release pull request or publish
32+
id: changesets
33+
uses: changesets/action@v1
34+
with:
35+
version: pnpm run ci:version
36+
commit: "chore: Update versions"
37+
title: "chore: Update versions"
38+
publish: pnpm run ci:publish
39+
env:
40+
# When you use the repository's GITHUB_TOKEN to perform tasks, events
41+
# triggered by the GITHUB_TOKEN will not create a new workflow run.
42+
# This means that checks won't run on the release PRs. We work around
43+
# this by using our own GH_TOKEN_REPO_ACCESS organization secret.
44+
GITHUB_TOKEN: ${{ secrets.GH_TOKEN_REPO_ACCESS }}

.github/workflows/release.yml

Lines changed: 0 additions & 80 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
push:
88
branches:
99
- main
10+
workflow_dispatch:
1011

1112
concurrency:
1213
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}

apps/storybook/.storybook/main.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ const config: StorybookConfig = {
1515
options: {},
1616
},
1717
viteFinal(config) {
18+
config.base = './';
19+
1820
config.define = {
1921
__DEV__: JSON.stringify(
2022
(config.mode ?? process.env.NODE_ENV) !== 'production',

apps/storybook/src/components/StorybookDecorator.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,12 @@ export function StorybookDecorator({
2828
new SdfTrFontFace('msdf', {
2929
fontFamily: 'sans-serif',
3030
descriptors: {},
31-
atlasUrl: '/fonts/ChocolateClassicalSans-Regular.msdf.png',
32-
atlasDataUrl: '/fonts/ChocolateClassicalSans-Regular.msdf.json',
31+
atlasUrl:
32+
import.meta.env.BASE_URL +
33+
'fonts/ChocolateClassicalSans-Regular.msdf.png',
34+
atlasDataUrl:
35+
import.meta.env.BASE_URL +
36+
'fonts/ChocolateClassicalSans-Regular.msdf.json',
3337
stage,
3438
}),
3539
],

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"type": "module",
1515
"scripts": {
1616
"build": "turbo build",
17+
"build:storybook": "pnpm run build --filter=@plextv/react-lightning-storybook",
1718
"build:types": "turbo build:types",
1819
"check:types": "turbo check:types",
1920
"clean": "turbo clean",

0 commit comments

Comments
 (0)