mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-29 02:32:18 +00:00
## Summary - Improves Storybook deployment and PR comment workflow similar to the Playwright improvements in #5425 - Creates unified deployment and commenting system for better maintainability - Adds Cloudflare Pages deployment for Storybook previews ## Deployment Cases Matrix | Case | PR Type | Branch | Deployment | Features | |------|---------|--------|------------|----------| | **1** | Non-forked PR | `version-bump-*` | ✅ Chromatic | • Visual diff testing<br>• Chromatic build URL<br>• Chromatic Storybook URL<br>• Shows visual changes | | **2** | Non-forked PR | All branches | ✅ Cloudflare Pages | • Live Storybook preview<br>• pages.dev URL<br>• No visual diff | | **3** | Forked PR | Any branch | ✅ Cloudflare Pages | • Live Storybook preview<br>• pages.dev URL<br>• No visual diff<br>• Runs via separate workflow to avoid permission problems | ### Key Points: - **Chromatic** (paid service): Only for `version-bump-*` branches to track visual changes between releases - **Cloudflare Pages** (free): For all other PRs to provide Storybook preview without visual diff - **Security**: Forked PRs use a separate workflow with limited permissions ## Changes ### New Features - 🚀 **Cloudflare Pages Deployment**: Storybook builds are now deployed to Cloudflare Pages for easy preview - 🔄 **Unified Script**: Single reusable shell script handles both deployment and PR comments - 🔒 **Better Security**: Separate workflows for fork vs non-fork PRs ### Improvements - ♻️ **Retry Logic**: Automatic retry (3 attempts) for failed deployments - 📝 **Better Comments**: Clearer PR comments with deployment links and status - 🎯 **Simplified Logic**: Workflow logic moved to reusable script for easier maintenance - ⚡ **Better Error Handling**: Proper handling of different workflow conclusions - 🐛 **Fixed Comment Output**: Deployment logs now properly redirected to stderr ### Files Changed - `scripts/cicd/pr-storybook-deploy-and-comment.sh` - New unified deployment script - `.github/workflows/chromatic.yaml` - Updated to use new script and add deployment - `.github/workflows/pr-storybook-deploy.yaml` - New workflow for forked PRs - `.github/workflows/pr-storybook-comment.yaml` - Removed (replaced by new system) ## ⚠️ Required Setup The Cloudflare Pages project `comfyui-storybook` needs to be created under the organization's Cloudflare account: ```bash # Using the account ID from GitHub secrets export CLOUDFLARE_ACCOUNT_ID=5ae914d9b87bcf6bbe1ada5798f92a5f export CLOUDFLARE_API_TOKEN=<org-token> wrangler pages project create comfyui-storybook --production-branch main ``` **Note**: The project must be created under the same Cloudflare account that's configured in the GitHub secrets. ## Test Plan - [x] Create Cloudflare Pages project `comfyui-storybook` - [x] Workflow runs successfully on all PRs - [x] PR comments are posted correctly at start and completion - [x] Storybook deploys to Cloudflare Pages with correct URL - [ ] Fork PRs are handled by separate workflow - [ ] Non-fork PRs get inline deployment - [ ] version-bump-* branches show Chromatic info ## References - Similar improvements for Playwright: #5459 - Based on pattern from sno-fix-playwright-comment-2 branch 🤖 Generated with [Claude Code](https://claude.ai/code) --------- Co-authored-by: Claude <noreply@anthropic.com>
90 lines
3.6 KiB
YAML
90 lines
3.6 KiB
YAML
name: PR Storybook Deploy (Forks)
|
|
|
|
on:
|
|
workflow_run:
|
|
workflows: ['Storybook and Chromatic CI']
|
|
types: [requested, completed]
|
|
|
|
env:
|
|
DATE_FORMAT: '+%m/%d/%Y, %I:%M:%S %p'
|
|
|
|
jobs:
|
|
deploy-and-comment-forked-pr:
|
|
runs-on: ubuntu-latest
|
|
if: |
|
|
github.repository == 'Comfy-Org/ComfyUI_frontend' &&
|
|
github.event.workflow_run.event == 'pull_request' &&
|
|
github.event.workflow_run.head_repository != null &&
|
|
github.event.workflow_run.repository != null &&
|
|
github.event.workflow_run.head_repository.full_name != github.event.workflow_run.repository.full_name
|
|
permissions:
|
|
pull-requests: write
|
|
actions: read
|
|
steps:
|
|
- name: Log workflow trigger info
|
|
run: |
|
|
echo "Repository: ${{ github.repository }}"
|
|
echo "Event: ${{ github.event.workflow_run.event }}"
|
|
echo "Head repo: ${{ github.event.workflow_run.head_repository.full_name || 'null' }}"
|
|
echo "Base repo: ${{ github.event.workflow_run.repository.full_name || 'null' }}"
|
|
echo "Is forked: ${{ github.event.workflow_run.head_repository.full_name != github.event.workflow_run.repository.full_name }}"
|
|
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Get PR Number
|
|
id: pr
|
|
uses: actions/github-script@v7
|
|
with:
|
|
script: |
|
|
const { data: prs } = await github.rest.pulls.list({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
state: 'open',
|
|
});
|
|
|
|
const pr = prs.find(p => p.head.sha === context.payload.workflow_run.head_sha);
|
|
|
|
if (!pr) {
|
|
console.log('No PR found for SHA:', context.payload.workflow_run.head_sha);
|
|
return null;
|
|
}
|
|
|
|
console.log(`Found PR #${pr.number} from fork: ${context.payload.workflow_run.head_repository.full_name}`);
|
|
return pr.number;
|
|
|
|
- name: Handle Storybook Start
|
|
if: steps.pr.outputs.result != 'null' && github.event.action == 'requested'
|
|
env:
|
|
GITHUB_TOKEN: ${{ github.token }}
|
|
run: |
|
|
chmod +x scripts/cicd/pr-storybook-deploy-and-comment.sh
|
|
./scripts/cicd/pr-storybook-deploy-and-comment.sh \
|
|
"${{ steps.pr.outputs.result }}" \
|
|
"${{ github.event.workflow_run.head_branch }}" \
|
|
"starting" \
|
|
"$(date -u '${{ env.DATE_FORMAT }}')"
|
|
|
|
- name: Download and Deploy Storybook
|
|
if: steps.pr.outputs.result != 'null' && github.event.action == 'completed' && github.event.workflow_run.conclusion == 'success'
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
run-id: ${{ github.event.workflow_run.id }}
|
|
name: storybook-static
|
|
path: storybook-static
|
|
|
|
- name: Handle Storybook Completion
|
|
if: steps.pr.outputs.result != 'null' && github.event.action == 'completed'
|
|
env:
|
|
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
|
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
|
GITHUB_TOKEN: ${{ github.token }}
|
|
WORKFLOW_CONCLUSION: ${{ github.event.workflow_run.conclusion }}
|
|
WORKFLOW_URL: ${{ github.event.workflow_run.html_url }}
|
|
run: |
|
|
chmod +x scripts/cicd/pr-storybook-deploy-and-comment.sh
|
|
./scripts/cicd/pr-storybook-deploy-and-comment.sh \
|
|
"${{ steps.pr.outputs.result }}" \
|
|
"${{ github.event.workflow_run.head_branch }}" \
|
|
"completed" |