1name: Thread Transfer Report
2
3on:
4 workflow_run:
5 workflows: [CI]
6 types: [completed]
7
8permissions:
9 actions: read
10 contents: read
11 pull-requests: write
12
13jobs:
14 publish:
15 name: Publish PR comment
16 if: github.event.workflow_run.event == 'pull_request'
17 runs-on: ubuntu-24.04
18 concurrency:
19 group: thread-transfer-report-${{ github.event.workflow_run.pull_requests[0].number || github.event.workflow_run.id }}
20 cancel-in-progress: true
21 steps:
22 # workflow_run has a write-capable token even for fork PRs. Only load the
23 # publisher from the trusted default branch and never execute PR code.
24 - name: Checkout trusted publisher
25 uses: actions/checkout@v6
26 with:
27 ref: ${{ github.event.repository.default_branch }}
28 sparse-checkout: .github/scripts
29
30 - name: Test trusted publisher
31 run: node --test .github/scripts/thread-transfer-report.test.cjs
32
33 - id: resolve
34 name: Resolve PR and baseline artifacts
35 uses: actions/github-script@v8
36 with:
37 script: |
38 const reporter = require("./.github/scripts/thread-transfer-report.cjs");
39 await reporter.resolve({ github, context, core });
40
41 - name: Download PR result
42 if: steps.resolve.outputs.publish == 'true' && steps.resolve.outputs.pr_artifact == 'true'
43 uses: actions/download-artifact@v8
44 with:
45 name: thread-transfer-results
46 path: ${{ runner.temp }}/thread-transfer/pr
47 github-token: ${{ secrets.GITHUB_TOKEN }}
48 run-id: ${{ steps.resolve.outputs.pr_run_id }}
49
50 - name: Download main baseline
51 if: steps.resolve.outputs.publish == 'true' && steps.resolve.outputs.baseline_artifact == 'true'
52 uses: actions/download-artifact@v8
53 with:
54 name: thread-transfer-results
55 path: ${{ runner.temp }}/thread-transfer/main
56 github-token: ${{ secrets.GITHUB_TOKEN }}
57 run-id: ${{ steps.resolve.outputs.baseline_run_id }}
58
59 - name: Update thread transfer comment
60 if: steps.resolve.outputs.publish == 'true'
61 uses: actions/github-script@v8
62 env:
63 PR_NUMBER: ${{ steps.resolve.outputs.pull_number }}
64 PR_SHA: ${{ steps.resolve.outputs.pr_sha }}
65 PR_CONCLUSION: ${{ steps.resolve.outputs.pr_conclusion }}
66 PR_RUN_ID: ${{ steps.resolve.outputs.pr_run_id }}
67 PR_RESULT_DIR: ${{ runner.temp }}/thread-transfer/pr
68 BASELINE_SHA: ${{ steps.resolve.outputs.baseline_sha }}
69 BASELINE_MATCHES_BASE: ${{ steps.resolve.outputs.baseline_matches_base }}
70 BASELINE_RUN_ID: ${{ steps.resolve.outputs.baseline_run_id }}
71 BASELINE_RESULT_DIR: ${{ runner.temp }}/thread-transfer/main
72 with:
73 script: |
74 const reporter = require("./.github/scripts/thread-transfer-report.cjs");
75 await reporter.publish({ github, context, core });