name: PR Playwright Deploy on: workflow_run: workflows: ["Tests CI"] types: [completed] jobs: deploy-reports: runs-on: ubuntu-latest if: github.repository == 'Comfy-Org/ComfyUI_frontend' && github.event.workflow_run.event == 'pull_request' permissions: actions: read strategy: fail-fast: false matrix: browser: [chromium, chromium-2x, chromium-0.5x, mobile-chrome] steps: - name: Get PR info id: pr-info uses: actions/github-script@v7 with: script: | const { data: pullRequests } = await github.rest.pulls.list({ owner: context.repo.owner, repo: context.repo.repo, state: 'open', head: `${context.repo.owner}:${context.payload.workflow_run.head_branch}`, }); if (pullRequests.length === 0) { console.log('No open PR found for this branch'); return { number: null, sanitized_branch: null }; } const pr = pullRequests[0]; const branchName = context.payload.workflow_run.head_branch; const sanitizedBranch = branchName.toLowerCase().replace(/[^a-z0-9-]/g, '-').replace(/--+/g, '-').replace(/^-|-$/g, ''); return { number: pr.number, sanitized_branch: sanitizedBranch }; - name: Set project name if: fromJSON(steps.pr-info.outputs.result).number != null id: project-name run: | if [ "${{ matrix.browser }}" = "chromium-0.5x" ]; then echo "name=comfyui-playwright-chromium-0-5x" >> $GITHUB_OUTPUT else echo "name=comfyui-playwright-${{ matrix.browser }}" >> $GITHUB_OUTPUT fi echo "branch=${{ fromJSON(steps.pr-info.outputs.result).sanitized_branch }}" >> $GITHUB_OUTPUT - name: Download playwright report if: fromJSON(steps.pr-info.outputs.result).number != null uses: actions/download-artifact@v4 with: github-token: ${{ secrets.GITHUB_TOKEN }} run-id: ${{ github.event.workflow_run.id }} name: playwright-report-${{ matrix.browser }} path: playwright-report - name: Install Wrangler if: fromJSON(steps.pr-info.outputs.result).number != null run: npm install -g wrangler - name: Deploy to Cloudflare Pages (${{ matrix.browser }}) if: fromJSON(steps.pr-info.outputs.result).number != null id: cloudflare-deploy continue-on-error: true run: | # Retry logic for wrangler deploy (3 attempts) RETRY_COUNT=0 MAX_RETRIES=3 SUCCESS=false while [ $RETRY_COUNT -lt $MAX_RETRIES ] && [ $SUCCESS = false ]; do RETRY_COUNT=$((RETRY_COUNT + 1)) echo "Deployment attempt $RETRY_COUNT of $MAX_RETRIES..." if npx wrangler pages deploy playwright-report --project-name=${{ steps.project-name.outputs.name }} --branch=${{ steps.project-name.outputs.branch }}; then SUCCESS=true echo "Deployment successful on attempt $RETRY_COUNT" else echo "Deployment failed on attempt $RETRY_COUNT" if [ $RETRY_COUNT -lt $MAX_RETRIES ]; then echo "Retrying in 10 seconds..." sleep 10 fi fi done if [ $SUCCESS = false ]; then echo "All deployment attempts failed" exit 1 fi env: CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}