70 lines
2.5 KiB
YAML
70 lines
2.5 KiB
YAML
name: CI review comment
|
|
|
|
# Live-updating PR review comment.
|
|
#
|
|
# The poller runs for up to 40 minutes.
|
|
# This run lives in its own workflow.
|
|
# A run stays in progress until its last job ends, and GitHub refuses
|
|
# ``gh run rerun`` on a run that is in progress.
|
|
#
|
|
# ``workflow_run`` starts this when CI starts. It always reads the workflow
|
|
# and the scripts from the default branch, never from the PR head.
|
|
# It makes a write token safe here.
|
|
#
|
|
# The poller reads job results through the API. Thus it watches the CI run
|
|
# and the separate docker run, and it depends on neither.
|
|
|
|
on:
|
|
workflow_run:
|
|
workflows: [CI]
|
|
types: [requested]
|
|
|
|
permissions:
|
|
contents: read
|
|
actions: read
|
|
pull-requests: write
|
|
|
|
# One poller per CI run. A new push starts a new CI run, and its poller
|
|
# cancels the poller of the run that GitHub superseded.
|
|
concurrency:
|
|
group: ci-review-comment-${{ github.event.workflow_run.head_branch }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
comment:
|
|
name: CI review comment (live)
|
|
# Fork PRs get no comment: the poller needs a write token, and the
|
|
# ``pull_requests`` payload is empty for a fork run.
|
|
if: >-
|
|
github.event.workflow_run.event == 'pull_request' &&
|
|
github.event.workflow_run.head_repository.full_name == github.repository
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 60
|
|
steps:
|
|
- name: Checkout trusted default branch
|
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
with:
|
|
ref: ${{ github.event.repository.default_branch }}
|
|
persist-credentials: false
|
|
|
|
- name: Run live comment poller
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
GITHUB_REPOSITORY: ${{ github.repository }}
|
|
# The CI run to report on — not this run.
|
|
GITHUB_RUN_ID: ${{ github.event.workflow_run.id }}
|
|
# Sibling runs for the same commit that the comment also covers,
|
|
# one workflow name per line (a name can contain a comma).
|
|
# The poller resolves each name to its runs through the API.
|
|
WATCH_WORKFLOWS: |
|
|
Docker Build, Test, and Publish
|
|
PR_NUMBER: ${{ github.event.workflow_run.pull_requests[0].number }}
|
|
RUN_URL: ${{ github.event.workflow_run.html_url }}
|
|
# Commit info for the review comment header.
|
|
COMMIT_SHA: ${{ github.event.workflow_run.head_sha }}
|
|
COMMIT_MESSAGE: ${{ github.event.workflow_run.head_commit.message }}
|
|
run: |
|
|
python3 scripts/ci/live_comment.py \
|
|
--interval 15 \
|
|
--timeout 3000
|