feat(branch-reports)!: feat(branch-reports): migrate docs/pages to .pages and update CI for Git\n\n- Remove and replace CI workflow for deploying GitHub Pages: deleted .github/workflows/deploy-gh-pages.yml; added .github/workflows/release-pages.yml to deploy to GitHub Pages and Vercel.\n- Reorganize docs assets: move docs/pages to .pages, renaming index.html, knip.html, and Vite config to .pages, and updating README accordingly.\n- Update Knip configuration to include new .pages path and adjust excludes.\n- Update build tooling and scripts to target the new .pages folder: add pages:dev and pages:build scripts, and adjust scripts/build-pages.sh to output to .pages.\n- Update package.json and TS/Vitest configs: include .pages in tsconfig; adjust vitest coverage settings to output under .vitest; add required reporters.\n- Remove legacy docs/pages ignores and tsconfig pointing at docs/pages; replace with .pages equivalents.\n- Note breaking changes: All generated docs/pages outputs are now under .pages. Existing paths, and GitHub Actions workflows expecting docs/pages are replaced by new .pages structure and the release-pages workflow.\n- New Knip HTML wrapper is now placed at .pages/knip.html.

This commit is contained in:
snomiao
2025-10-14 10:31:38 +00:00
parent e4de597460
commit 46d2fd594e
14 changed files with 270 additions and 241 deletions

View File

@@ -1,174 +0,0 @@
name: Deploy to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
actions: read
on:
# Trigger after successful CI workflows complete
workflow_run:
workflows: ["Storybook and Chromatic CI", "Vitest Tests", "Tests CI"]
types: [completed]
branches: [main]
# Allow direct pushes to the debug branch to kick off the full pipeline
push:
branches: [sno-deploy-ghpage]
# Keep manual trigger for debugging
workflow_dispatch:
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
build:
runs-on: ubuntu-latest
# Only run if the triggering workflow succeeded (or manual dispatch/push)
if: github.event_name == 'workflow_dispatch' || github.event_name == 'push' || github.event.workflow_run.conclusion == 'success'
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 10
- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version: '24'
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Download Storybook artifact from latest CI run
continue-on-error: true
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "🔍 Downloading latest Storybook artifact..."
# Get latest successful Storybook workflow run
LATEST_RUN=$(gh api "repos/${{ github.repository }}/actions/workflows" \
--jq '.workflows[] | select(.name == "Storybook and Chromatic CI") | .id' | head -1)
if [ -n "$LATEST_RUN" ]; then
RUN_ID=$(gh api "repos/${{ github.repository }}/actions/workflows/$LATEST_RUN/runs?status=success&branch=main" \
--jq '.workflow_runs[0].id' 2>/dev/null || echo "")
if [ -n "$RUN_ID" ] && [ "$RUN_ID" != "null" ]; then
# Download storybook-static artifact
ARTIFACT_ID=$(gh api "repos/${{ github.repository }}/actions/runs/$RUN_ID/artifacts" \
--jq '.artifacts[] | select(.name == "storybook-static") | .id' | head -1)
if [ -n "$ARTIFACT_ID" ]; then
gh api "repos/${{ github.repository }}/actions/artifacts/$ARTIFACT_ID/zip" > storybook-static.zip
unzip -q storybook-static.zip -d ./storybook-static
echo "✅ Downloaded and extracted Storybook artifact"
else
echo "⚠️ Storybook artifact not found, will build from source"
fi
else
echo "⚠️ No successful Storybook runs found, will build from source"
fi
else
echo "⚠️ Storybook workflow not found, will build from source"
fi
- name: Download Vitest reports from latest CI run
continue-on-error: true
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "🔍 Downloading latest Vitest reports..."
# Get latest successful Vitest workflow run
LATEST_RUN=$(gh api "repos/${{ github.repository }}/actions/workflows" \
--jq '.workflows[] | select(.name == "Vitest Tests") | .id' | head -1)
if [ -n "$LATEST_RUN" ]; then
RUN_ID=$(gh api "repos/${{ github.repository }}/actions/workflows/$LATEST_RUN/runs?status=success&branch=main" \
--jq '.workflow_runs[0].id' 2>/dev/null || echo "")
if [ -n "$RUN_ID" ] && [ "$RUN_ID" != "null" ]; then
# Download vitest-reports artifact
ARTIFACT_ID=$(gh api "repos/${{ github.repository }}/actions/runs/$RUN_ID/artifacts" \
--jq '.artifacts[] | select(.name == "vitest-reports") | .id' | head -1)
if [ -n "$ARTIFACT_ID" ]; then
mkdir -p ./.gh-pages-cache
gh api "repos/${{ github.repository }}/actions/artifacts/$ARTIFACT_ID/zip" > vitest-reports.zip
unzip -q vitest-reports.zip -d ./.gh-pages-cache/vitest-reports
echo "✅ Downloaded and extracted Vitest reports"
else
echo "⚠️ Vitest reports not found, will generate from source"
fi
else
echo "⚠️ No successful Vitest runs found, will generate from source"
fi
else
echo "⚠️ Vitest workflow not found, will generate from source"
fi
- name: Build static assets (with artifact reuse)
run: ./scripts/build-pages.sh
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Upload built pages as cache
uses: actions/upload-pages-artifact@v3
with:
name: built-pages
path: './docs/pages'
# deploy-for-sno-deploy-ghpage-branch:
# runs-on: ubuntu-latest
# needs: build
# if: github.ref == 'refs/heads/sno-deploy-ghpage'
# steps:
# - name: Debug deployment
# run: |
# echo "Contents of ./docs/pages:"
# ls -la ./docs/pages
# echo "Contents of ./docs/pages/vitest-reports (if exists):"
# ls -la ./docs/pages/vitest-reports || echo "No vitest-reports directory"
# echo "Preview URL: https://comfyorg-comfyui-frontend.vercel.app"
deploy-github-pages:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
deploy-vercel-app:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: download built pages
uses: actions/download-artifact@v3
with:
name: built-pages
path: ./docs/pages
- name: Deploy to Vercel
uses: amondnet/vercel-action@v20
with:
vercel-token: ${{ secrets.VERCEL_TOKEN }} # Required
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }} # Required
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }} # Required
working-directory: ./docs/pages
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} # Required for Vercel Action

152
.github/workflows/release-pages.yml vendored Normal file
View File

@@ -0,0 +1,152 @@
name: Deploy to GitHub Pages
on:
# Triggers when any of these workflows complete on main branch
# Runs ONCE per workflow completion (e.g., if "Vitest Tests" completes, this workflow runs once)
workflow_run:
workflows: ['Storybook and Chromatic CI', 'Vitest Tests', 'Tests CI']
types: [completed]
# Allow direct pushes to the debug branch to kick off the full pipeline
push:
branches: [sno-deploy-ghpage]
# Keep manual trigger for debugging
workflow_dispatch:
jobs:
incremental-build:
runs-on: ubuntu-latest
# Only run if the triggering workflow succeeded (or manual dispatch/push)
if: github.event_name == 'workflow_dispatch' || github.event_name == 'push' || github.event.workflow_run.conclusion == 'success'
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 10
- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version: '24'
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Download Storybook artifact (source run)
id: fetch_storybook_trigger
continue-on-error: true
if: github.event_name == 'workflow_run' && github.event.workflow_run.name == 'Storybook and Chromatic CI'
uses: actions/download-artifact@v4
with:
name: storybook-static
path: storybook-static
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Download Storybook artifact (latest successful run on main)
continue-on-error: true
if: steps.fetch_storybook_trigger.outcome != 'success'
uses: dawidd6/action-download-artifact@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
workflow: storybook-and-chromatic-ci.yaml
name: storybook-static
branch: main
workflow_conclusion: success
path: storybook-static
- name: Download Vitest reports (source run)
id: fetch_vitest_trigger
continue-on-error: true
if: github.event_name == 'workflow_run' && github.event.workflow_run.name == 'Vitest Tests'
uses: actions/download-artifact@v4
with:
name: vitest-reports
path: ./.pages
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Download Vitest reports (latest successful run on main)
continue-on-error: true
if: steps.fetch_vitest_trigger.outcome != 'success'
uses: dawidd6/action-download-artifact@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
workflow: vitest-tests.yaml
name: vitest-reports
branch: main
workflow_conclusion: success
path: ./.pages
- name: Build static assets (with artifact reuse)
run: ./scripts/build-pages.sh
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Upload built pages as cache
uses: actions/upload-pages-artifact@v3
with:
name: built-pages
path: './docs/pages'
# deploy-for-sno-deploy-ghpage-branch:
# runs-on: ubuntu-latest
# needs: build
# if: github.ref == 'refs/heads/sno-deploy-ghpage'
# steps:
# - name: Debug deployment
# run: |
# echo "Contents of ./docs/pages:"
# ls -la ./docs/pages
# echo "Contents of ./docs/pages/vitest-reports (if exists):"
# ls -la ./docs/pages/vitest-reports || echo "No vitest-reports directory"
# echo "Preview URL: https://comfyorg-comfyui-frontend.vercel.app"
incremental-deploy-github-pages:
permissions:
contents: read
pages: write
id-token: write
actions: read
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: incremental-build
steps:
# - [Feature request: Partial upload/deploy · Issue #349 · actions/deploy-pages]( https://github.com/actions/deploy-pages/issues/349 )
- name: Checkout code
uses: actions/checkout@v5
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
deploy-vercel-app:
runs-on: ubuntu-latest
needs: incremental-build
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: download built pages
uses: actions/download-artifact@v3
with:
name: built-pages
path: ./docs/pages
- name: Deploy to Vercel
uses: amondnet/vercel-action@v20
with:
vercel-token: ${{ secrets.VERCEL_TOKEN }} # Required
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }} # Required
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }} # Required
working-directory: ./docs/pages
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} # Required for Vercel Action