From 35749ed1ed8f3f567d1d8ae2f6dbdc3bd8582cc5 Mon Sep 17 00:00:00 2001 From: dkanada Date: Sat, 14 Mar 2026 13:12:23 +0900 Subject: [PATCH] move broken actions to workflow_run event --- .github/workflows/__deploy.yml | 26 ++++++++++++-- .github/workflows/__job_messages.yml | 4 +++ .github/workflows/pull_request.yml | 35 +------------------ .github/workflows/workflow_run.yml | 51 ++++++++++++++++++++++++++++ 4 files changed, 79 insertions(+), 37 deletions(-) create mode 100644 .github/workflows/workflow_run.yml diff --git a/.github/workflows/__deploy.yml b/.github/workflows/__deploy.yml index 82d6cfed02..d91ecaa896 100644 --- a/.github/workflows/__deploy.yml +++ b/.github/workflows/__deploy.yml @@ -12,17 +12,35 @@ on: comment: required: false type: boolean + pr_number: + required: true + type: number + workflow_run_id: + required: true + type: number artifact_name: required: false type: string default: frontend jobs: + progress-comment: + name: Progress Comment + if: ${{ always() }} + uses: ./.github/workflows/__job_messages.yml + secrets: inherit + with: + branch: ${{ inputs.branch }} + commit: ${{ inputs.commit }} + pr_number: ${{ inputs.pr_number }} + comment: true + in_progress: true + cf-pages: name: CloudFlare Pages ๐Ÿ“ƒ runs-on: ubuntu-latest environment: - name: ${{ inputs.branch == 'master' && 'Production' || 'Preview' }} + name: ${{ inputs.branch == 'jellyfin/jellyfin-web/master' && 'Production' || 'Preview' }} url: ${{ steps.cf.outputs.deployment-url }} outputs: url: ${{ steps.cf.outputs.deployment-url }} @@ -33,6 +51,8 @@ jobs: with: name: ${{ inputs.artifact_name }} path: dist + run-id: ${{ inputs.workflow_run_id }} + github-token: ${{ github.token }} - name: Publish to Cloudflare Pages ๐Ÿ“ƒ uses: cloudflare/wrangler-action@da0e0dfe58b7a431659754fdf3f186c529afbe65 # v3.14.1 @@ -50,10 +70,10 @@ jobs: secrets: inherit needs: - cf-pages - with: branch: ${{ inputs.branch }} commit: ${{ inputs.commit }} preview_url: ${{ needs.cf-pages.outputs.url }} + pr_number: ${{ inputs.pr_number }} + comment: true in_progress: false - comment: ${{ inputs.comment }} diff --git a/.github/workflows/__job_messages.yml b/.github/workflows/__job_messages.yml index 5c63d02bbe..cb1cd6fe7c 100644 --- a/.github/workflows/__job_messages.yml +++ b/.github/workflows/__job_messages.yml @@ -18,6 +18,9 @@ on: comment: required: false type: boolean + pr_number: + required: true + type: number marker: description: Hidden marker to detect PR comments composed by the bot required: false @@ -63,3 +66,4 @@ jobs: github-token: ${{ secrets.JF_BOT_TOKEN }} message: ${{ env.msg }} comment-tag: ${{ inputs.marker }} + pr-number: ${{ inputs.pr_number }} diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index b557f6553a..88eec9f3b4 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -1,4 +1,4 @@ -name: Pull Request ๐Ÿ“ฅ +name: Pull Request concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }} @@ -14,16 +14,6 @@ on: merge_group: jobs: - push-comment: - name: Create comments โœ๏ธ - if: ${{ always() && !cancelled() && github.repository == 'jellyfin/jellyfin-web' }} - uses: ./.github/workflows/__job_messages.yml - secrets: inherit - with: - commit: ${{ github.event.pull_request.head.sha }} - in_progress: true - comment: true - build: name: Build ๐Ÿ—๏ธ if: ${{ always() && !cancelled() }} @@ -31,12 +21,6 @@ jobs: with: commit: ${{ github.event.pull_request.head.sha }} - automation: - name: Automation ๐ŸŽ›๏ธ - if: ${{ github.repository == 'jellyfin/jellyfin-web' }} - uses: ./.github/workflows/__automation.yml - secrets: inherit - quality_checks: name: Quality checks ๐Ÿ‘Œ๐Ÿงช if: ${{ always() && !cancelled() }} @@ -56,23 +40,6 @@ jobs: with: commit: ${{ github.event.pull_request.head.sha }} - deploy: - name: Deploy ๐Ÿš€ - uses: ./.github/workflows/__deploy.yml - if: ${{ always() && !cancelled() && needs.build.result == 'success' && github.repository == 'jellyfin/jellyfin-web' }} - needs: - - push-comment - - build - permissions: - contents: read - deployments: write - secrets: inherit - with: - # If the PR is from the master branch of a fork, append the fork's name to the branch name - branch: ${{ github.event.pull_request.head.repo.full_name != github.repository && github.event.pull_request.head.ref == 'master' && format('{0}/{1}', github.event.pull_request.head.repo.full_name, github.event.pull_request.head.ref) || github.event.pull_request.head.ref }} - comment: true - commit: ${{ github.event.pull_request.head.sha }} - run-eslint: name: Run eslint suggestions if: ${{ github.repository == 'jellyfin/jellyfin-web' }} diff --git a/.github/workflows/workflow_run.yml b/.github/workflows/workflow_run.yml new file mode 100644 index 0000000000..6d72c949e5 --- /dev/null +++ b/.github/workflows/workflow_run.yml @@ -0,0 +1,51 @@ +name: Workflow Run + +concurrency: + group: ${{ github.workflow }}-${{ github.event.workflow_run.head_branch }} + cancel-in-progress: true + +on: + workflow_run: + workflows: + - Pull Request + types: + - completed + +jobs: + metadata: + name: Metadata + runs-on: ubuntu-latest + outputs: + pr_number: ${{ steps.pr_number.outputs.pr_number }} + steps: + - name: Get Pull Request Number + id: pr_number + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }} + run: | + echo "pr_number=$(gh pr list --repo "${GITHUB_REPOSITORY}" --head "${HEAD_BRANCH}" --json number --jq '.[0].number')" >> "${GITHUB_OUTPUT}" + + automation: + name: Automation + uses: ./.github/workflows/__automation.yml + permissions: + contents: read + issues: write + secrets: inherit + + deploy: + name: Deploy + uses: ./.github/workflows/__deploy.yml + permissions: + contents: read + issues: write + deployments: write + secrets: inherit + needs: + - metadata + with: + branch: ${{ format('{0}/{1}', github.event.workflow_run.head_repository.full_name, github.event.workflow_run.head_branch) }} + commit: ${{ github.event.workflow_run.head_sha }} + workflow_run_id: ${{ github.event.workflow_run.id }} + pr_number: ${{ needs.metadata.outputs.pr_number }}