Skip to content

Commit 21275b2

Browse files
Merge pull request #19882 from mozilla/FXA-12875
feat(storybooks): build storybooks for affected packages only for PRs
2 parents 253a8fd + 1c04973 commit 21275b2

2 files changed

Lines changed: 36 additions & 2 deletions

File tree

.github/workflows/deploy-storybooks.yml

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,25 @@ jobs:
1616
build:
1717
name: Build Storybooks
1818
runs-on: ubuntu-latest
19+
outputs:
20+
has_storybooks: ${{ steps.check-affected.outputs.has_storybooks || 'true' }}
1921

2022
steps:
2123
- name: Checkout repository
2224
uses: actions/checkout@v6
2325
with:
2426
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
27+
fetch-depth: 0
28+
filter: tree:0
29+
30+
- name: Set NX_BASE and NX_HEAD for affected detection
31+
if: github.event_name == 'pull_request'
32+
run: |
33+
git fetch origin ${{ github.base_ref }}
34+
MERGE_BASE=$(git merge-base HEAD origin/${{ github.base_ref }})
35+
echo "NX_BASE=$MERGE_BASE" >> $GITHUB_ENV
36+
echo "NX_HEAD=HEAD" >> $GITHUB_ENV
37+
echo "Comparing against merge-base: $MERGE_BASE"
2538
2639
- name: Setup Node.js
2740
uses: actions/setup-node@v6
@@ -35,15 +48,36 @@ jobs:
3548
- name: Clone l10n repository
3649
run: _scripts/l10n/clone.sh
3750

38-
- name: Build all Storybooks
51+
- name: Check if any projects with storybook are affected (PR)
52+
id: check-affected
53+
if: github.event_name == 'pull_request'
54+
run: |
55+
AFFECTED=$(npx nx show projects --affected -t build-storybook)
56+
if [ -z "$AFFECTED" ]; then
57+
echo "has_storybooks=false" >> $GITHUB_OUTPUT
58+
echo "No storybook projects affected"
59+
else
60+
echo "has_storybooks=true" >> $GITHUB_OUTPUT
61+
echo "Affected storybook projects:"
62+
echo "$AFFECTED"
63+
fi
64+
65+
- name: Build Storybooks for affected packages (PR)
66+
if: github.event_name == 'pull_request' && steps.check-affected.outputs.has_storybooks == 'true'
67+
run: npx nx affected -t build-storybook
68+
69+
- name: Build all Storybooks (main branch)
70+
if: github.event_name == 'push'
3971
run: npx nx run-many -t build-storybook
4072

4173
- name: Organize Storybooks for deployment
74+
if: github.event_name == 'push' || steps.check-affected.outputs.has_storybooks == 'true'
4275
run: node _scripts/organize-storybooks.js
4376
env:
4477
DEPLOY_DIR: deploy/
4578

4679
- name: Upload storybooks artifact
80+
if: github.event_name == 'push' || steps.check-affected.outputs.has_storybooks == 'true'
4781
uses: actions/upload-artifact@v6
4882
with:
4983
name: storybooks-${{ github.event_name == 'pull_request' && github.event.pull_request.number || 'main' }}
@@ -54,6 +88,7 @@ jobs:
5488
name: Deploy to GitHub Pages
5589
runs-on: ubuntu-latest
5690
needs: build
91+
if: needs.build.outputs.has_storybooks == 'true'
5792
# Single concurrency group to prevent conflicts
5893
concurrency:
5994
group: gh-pages-deploy

packages/fxa-payments-server/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
"build-ts": "tsc",
1010
"build-l10n": "nx l10n-merge && nx l10n-bundle && nx l10n-merge-test",
1111
"build-react": "SKIP_PREFLIGHT_CHECK=true PUBLIC_URL=/ INLINE_RUNTIME_CHUNK=false CI=false NODE_OPTIONS=--openssl-legacy-provider rescripts build",
12-
"build-storybook": "NODE_OPTIONS=--openssl-legacy-provider storybook build && cp -r public/images storybook-static/ && cp -r public/locales ./storybook-static/locales",
1312
"compile": "tsc --noEmit",
1413
"clean": "rimraf dist",
1514
"l10n-merge": "yarn grunt merge-ftl",

0 commit comments

Comments
 (0)