pr-post-ci #1143
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
| # SPEC: docs/spec/governance/SPEC-Governance-PR-Post-CI-v1.md | |
| # CI 完成后更新 PR body(CI 表 + Test plan 勾选 + 变更统计);不替代人写 Summary。 | |
| name: pr-post-ci | |
| on: | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| workflow_run: | |
| workflows: | |
| - pytest | |
| - tech-graph | |
| - tech-graph-contract | |
| - verify-fast | |
| types: [completed] | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| jobs: | |
| update-pr-body: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| if: >- | |
| github.event_name == 'pull_request' || | |
| (github.event.workflow_run.conclusion != 'cancelled' && | |
| github.event.workflow_run.event == 'pull_request') | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| - name: Resolve PR number | |
| id: pr | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| set -euo pipefail | |
| if [ "${{ github.event_name }}" = "pull_request" ]; then | |
| echo "number=${{ github.event.pull_request.number }}" >> "$GITHUB_OUTPUT" | |
| else | |
| sha="${{ github.event.workflow_run.head_sha }}" | |
| num=$(gh pr list --state open --json number,headRefOid \ | |
| --jq ".[] | select(.headRefOid==\"$sha\") | .number" | head -1) | |
| if [ -z "$num" ]; then | |
| echo "No open PR for $sha; skip." | |
| echo "number=" >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| echo "number=$num" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Update PR body | |
| if: steps.pr.outputs.number != '' | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| pip install -q 'requests>=2.28' | |
| python tools/pr_post_ci_update_body.py --pr "${{ steps.pr.outputs.number }}" |