From 29903d106225a9ef6b017fa06476f7a113401fa9 Mon Sep 17 00:00:00 2001 From: Efra Espada Date: Thu, 12 Nov 2026 10:58:23 +0100 Subject: [PATCH] ci: archive Storybook for Pages in the Linux build container --- .github/scripts/verify-catalog.sh | 5 +++++ .github/workflows/storybook_pages.yml | 8 ++++++-- docs/storybook.md | 4 ++-- tests/architecture.test.mjs | 6 ++++++ 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/.github/scripts/verify-catalog.sh b/.github/scripts/verify-catalog.sh index 3e40fda..54fd60a 100644 --- a/.github/scripts/verify-catalog.sh +++ b/.github/scripts/verify-catalog.sh @@ -43,4 +43,9 @@ npm exec --yes --package="node@$HA_UI_NODE_VERSION" --package="$package_manager" pnpm test:engines pnpm test:storybook ' + +test -f build/storybook/index.html +tar --dereference --hard-dereference \ + --directory build/storybook --create --file /workspace/build/artifact.tar \ + --exclude=.git --exclude=.github --exclude=".[^/]*" . LINUX diff --git a/.github/workflows/storybook_pages.yml b/.github/workflows/storybook_pages.yml index 2f265b6..67e5eb7 100644 --- a/.github/workflows/storybook_pages.yml +++ b/.github/workflows/storybook_pages.yml @@ -28,9 +28,13 @@ jobs: - name: Build and verify Storybook in Linux shell: bash run: bash .github/scripts/verify-catalog.sh - - uses: actions/upload-pages-artifact@7b1f4a764d45c48632c6b24a0339c27f5614fb0b # v4 + - name: Upload the verified Pages archive + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 with: - path: build/storybook + name: github-pages + path: build/artifact.tar + retention-days: 1 + if-no-files-found: error deploy: needs: build runs-on: ubuntu-latest diff --git a/docs/storybook.md b/docs/storybook.md index 7c42913..9a21927 100644 --- a/docs/storybook.md +++ b/docs/storybook.md @@ -90,8 +90,8 @@ Every branch push to this repository runs `CI Check`, including strict types, fu the static catalog build and the static browser gate. An internal pull request shows CI for its pushed head. Bring the head up to date with the target branch before merging. Its retained artifact includes `build/storybook/`, coverage and browser evidence. This makes a candidate reviewable before merge. The separate Pages -workflow builds and rechecks trusted `master` before upload; only its deployment job receives Pages -write and OIDC permission. It never executes PR code with deployment permissions. +workflow builds and rechecks trusted `master`, then creates the Pages archive inside the same Linux container. +Only its deployment job receives Pages write and OIDC permission. Fork workflows require maintainer approval in GitHub. CI and the Pages build use Apple Silicon runners in the organization's `vypdev` group. diff --git a/tests/architecture.test.mjs b/tests/architecture.test.mjs index ec517a7..89f4d1e 100644 --- a/tests/architecture.test.mjs +++ b/tests/architecture.test.mjs @@ -173,6 +173,12 @@ test('Pages builds only the trusted default branch and grants write permissions expect(verify).toContain('--platform linux/arm64'); expect(verify).toContain('--env npm_config_store_dir=/tmp/ha-ui-pnpm-store'); expect(verify).not.toContain('playwright install'); + expect(verify.indexOf('tar --dereference --hard-dereference')).toBeGreaterThan(verify.indexOf('pnpm test:storybook')); + expect(verify).toContain('--directory build/storybook --create --file /workspace/build/artifact.tar'); + const archive = build.steps.find(step => step.uses?.startsWith('actions/upload-artifact@')); + expect(archive.with).toEqual({ + name: 'github-pages', path: 'build/artifact.tar', 'retention-days': 1, 'if-no-files-found': 'error', + }); for (const command of ['pnpm install --frozen-lockfile --ignore-scripts', 'pnpm check', 'pnpm test', 'pnpm test:package', 'pnpm test:ssr', 'pnpm storybook:build', 'pnpm test:storybook', 'pnpm test:engines']) { expect(verify.split('\n').some(line => line.trimEnd().endsWith(' '+command))).toBe(true);