-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Checkout the test merge of a PR, rather than the head of the PR branch #15
Comments
FYI I've also sent a support request (ticket # 353792) to GitHub asking for an environment variable to be added which gives us the PR number. |
You can get the PR number by doing this for now: |
If your workflow triggers on the |
I was able to confirm that it's just this easy. Adding the
Maybe it was the docs that threw me off initially. It looked like the
Worth calling out for others that may have missed this like me: one of the events that triggers |
Thanks everyone for input here. I believe it was the docs that led me down the wrong path, as @Ignigena demonstrates. 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
But it seems that GH actions is clever enough not to trigger a rebuild of a commit that was already built. |
@Ignigena Can you point me to an action where you do that? I currently have my tests run on push and pull_request events which is pretty pointless if they both test against the unmerged branch. |
@AlCalzone if you are using the |
@adamralph ok thanks. I guess I misunderstood Ignigena's comment then. |
Hi @Ignigena 👋, the |
What if I don't want to run it on a merge with the target branch and instead run it on the PR as it exists on the topic (e.g., run even if it has merge conflicts)? Is there some setting available to do that? |
@mathstuf I believe, in that case, you should be using the |
I now see that this is actually a different issue. |
Sorry, just saw you reply. This action I'm writing should only run on PRs though (it submits check statuses based on PR metadata and the branch itself as it exists). |
Since this is larger than this repo, I filed an issue on the community page. |
According to actions/checkout#15 (comment), GA when triggered by a pull request will check out the merged state of the repo. Also therefore no need to clone to depth greater than 1.
* GA: remove merging with upstream branch According to actions/checkout#15 (comment), GA when triggered by a pull request will check out the merged state of the repo. Also therefore no need to clone to depth greater than 1. * Fix pre-commit check range
According to actions/checkout#15 (comment) if we run on pull_requests instead of on push, we'll get the merged version of the repo rather than the pull request branch.
See discussion: actions/checkout#15
I've read through the thread, we have the configuration according to the comments and docs: on:
push:
branches: [ main ]
pull_request:
branches: [ main ] (same YAML across all opened PRs and yet I do not see GitHub Actions rebuilding PRs when other PR gets merged into Expected behavior
Observed behavior
|
@artem-zinnatullin I would open a new issue for that. This issue is for something else. |
Took me a while to find this, but this is mentioned in the docs. |
This is extremely thinly documented but it seems that just using the `sha` provided on a pull_request event will give us the functionality that was previously implemented here by checking out the pull request head and merging in the target branch. This is the best reference I could find: actions/checkout#15 (comment) With these changes our code for pull requests is quite similar to that for branches, we're just configuring the current user name here. Maybe we should merge those branches and always configure the user?
When does the |
Right one would need to update the PR branch (perhaps using this feature). This would be needed anyways to rerun CI. Alternatively one could close and reopen the PR, which would also trigger this update (and CI rerun) |
When I create a PR,
actions/checkout
checks out the head of the PR branch. For example, if the head of the PR branch has the SHAcc87b2733dfbe579a4451b2359191a6c512207c3
, I see this in the GitHub CI log:Whereas most 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:
And in the Appveyor log I see:
actions/checkout
should check out the test merge of a PR, rather than the head of the PR branch. Or it should at least have an option to do that.The text was updated successfully, but these errors were encountered: