有没有办法让 GitHub CI 构建 PR 的测试合并,而不是 PR 分支的负责人?

Is there a way to make GitHub CI build the test merge of a PR, rather than the head of the PR branch?

当我创建 PR 时,GitHub CI(通过 actions/checkout 操作)检查 PR 分支的负责人。例如,如果 PR 分支的负责人拥有 SHA cc87b2733dfbe579a4451b2359191a6c512207c3,我会在 GitHub CI 日志中看到:

git checkout --progress --force cc87b2733dfbe579a4451b2359191a6c512207c3

而其他 CI 系统检查 PR 的 test merge。例如,如果 PR 编号是 123,在 Travis CI 日志中我看到:

git fetch origin +refs/pull/123/merge
git checkout -qf FETCH_HEAD

在 Appveyor 日志中我看到:

git fetch -q origin +refs/pull/123/merge
git checkout -qf FETCH_HEAD

有没有办法让 GitHub CI 构建 PR 的测试合并,而不是 PR 分支的头部?

根据https://github.com/actions/checkout/issues/15:

GitHub 文档具有误导性:

If you intend to use the pull_request event to trigger CI tests, we recommend that you set up your workflow configuration to listen to the push event.

我发现以下内容完全符合我的要求:

on:
  push:
  - master
  - release-*
  pull_request:

我担心使用 pull_request 事件会触发太多构建,因为根据 docs:

Triggered when a pull request is assigned, unassigned, labeled, unlabeled, opened, edited, closed, reopened, synchronize, ready_for_review, locked, unlocked or when a pull request review is requested or removed.

但 GH 操作似乎足够聪明,不会触发对已构建提交的重建。