Files
ComfyUI_frontend/.github/workflows/deploy-gh-pages.yml
2025-10-14 03:58:38 +00:00

148 lines
5.3 KiB
YAML

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]
# 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)
if: github.event_name == 'workflow_dispatch' || 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-gh-pages.sh
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
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:
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