CI: Tests Storybook (Deploy for Forks) #59388
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Description: Deploys Storybook previews from forked PRs (forks can't access deployment secrets) | |
| name: 'CI: Tests Storybook (Deploy for Forks)' | |
| on: | |
| workflow_run: | |
| workflows: ['CI: Tests Storybook'] | |
| types: [requested, completed] | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.workflow_run.head_repository.full_name }}-${{ github.event.workflow_run.head_branch }} | |
| cancel-in-progress: true | |
| 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@v7 | |
| - name: Resolve PR from workflow_run context | |
| id: pr | |
| uses: ./.github/actions/resolve-pr-from-workflow-run | |
| - name: Handle Storybook Start — upsert storybook starting section | |
| if: steps.pr.outputs.skip != 'true' && github.event.action == 'requested' | |
| uses: ./.github/actions/upsert-comment-section | |
| with: | |
| pr-number: ${{ steps.pr.outputs.number }} | |
| section-name: storybook | |
| section-content: '## 🎨 Storybook: 🚧 Building...' | |
| comment-marker: '<!-- COMFYUI_FRONTEND_PR_REPORT -->' | |
| token: ${{ github.token }} | |
| - name: Download and Deploy Storybook | |
| if: steps.pr.outputs.skip != 'true' && github.event.action == 'completed' && github.event.workflow_run.conclusion == 'success' | |
| uses: actions/download-artifact@v8 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| run-id: ${{ github.event.workflow_run.id }} | |
| name: storybook-static | |
| path: storybook-static | |
| - name: Handle Storybook Completion — deploy and generate section | |
| if: steps.pr.outputs.skip != 'true' && 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 }} | |
| SUMMARY_FILE: storybook-section.md | |
| BRANCH_NAME: ${{ github.event.workflow_run.head_branch }} | |
| run: | | |
| chmod +x scripts/cicd/pr-storybook-deploy-and-comment.sh | |
| ./scripts/cicd/pr-storybook-deploy-and-comment.sh \ | |
| "${{ steps.pr.outputs.number }}" \ | |
| "$BRANCH_NAME" \ | |
| "completed" | |
| - name: Read storybook section | |
| id: section | |
| if: steps.pr.outputs.skip != 'true' && github.event.action == 'completed' && hashFiles('storybook-section.md') != '' | |
| uses: juliangruber/read-file-action@271ff311a4947af354c6abcd696a306553b9ec18 # v1.1.8 | |
| with: | |
| path: storybook-section.md | |
| - name: Upsert storybook section into unified report | |
| if: steps.pr.outputs.skip != 'true' && github.event.action == 'completed' && steps.section.outputs.content != '' | |
| uses: ./.github/actions/upsert-comment-section | |
| with: | |
| pr-number: ${{ steps.pr.outputs.number }} | |
| section-name: storybook | |
| section-content: ${{ steps.section.outputs.content }} | |
| comment-marker: '<!-- COMFYUI_FRONTEND_PR_REPORT -->' | |
| token: ${{ github.token }} |