When I create a PR, GitHub CI (via the actions/checkout
action) checks out the head of the PR branch. For example, if the head of the PR branch has the SHA cc87b2733dfbe579a4451b2359191a6c512207c3
, I see this in the GitHub CI log:
git checkout --progress --force cc87b2733dfbe579a4451b2359191a6c512207c3
Whereas other CI systems check out the test merge of the PR. For example, if the PR number is 123, in the Travis CI log I see:
git fetch origin +refs/pull/123/merge
git checkout -qf FETCH_HEAD
And in the Appveyor log I see:
git fetch -q origin +refs/pull/123/merge
git checkout -qf FETCH_HEAD
Is there a way to make GitHub CI build the test merge of a PR, rather than the head of the PR branch?
As per https://github.com/actions/checkout/issues/15:
The GitHub docs are misleading:
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 thepush
event.
I've discovered that the following works exactly as I want:
on:
push:
- master
- release-*
pull_request:
I was concerned that I would get too many builds triggered using the pull_request
event, since according to the 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.
But it seems that GH actions is clever enough not to trigger a rebuild of a commit that was already built.