-
Notifications
You must be signed in to change notification settings - Fork 53
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
Prevent tasks from running on Pull Request builds #800
Comments
The logic for identifying a PR is:
However, in an example PR, the following values are in play:
|
@gep13 the build check you are linking to is not actually the pull request build, but rather a build that gets ran due to the push to a local branch. I answered a similar (or actually the same question) here: cake-build/cake#3200 |
The failure you are seeing should be able to be resolved by a user when #775 is released. EDIT: fixed issue link |
Hmmm.... thanks for pointing this out! While the skip duplicate would prevent this issue, I also don't want any pre-release packages being pushed when it is a PR build (whether is it the PR branch itself or a local branch from same repository). I am assuming that this can be fixed by preventing the build to only specific named branches on local repository? |
Indeed, but that is probably something that should be done in a workflow and not in Cake.Recipe itself. |
Am I wrong in saying that we can use the event name, either from the environment variables, or by deserializing the event as done here: https://github.com/benfoster/o9d-guard/blob/main/build.cake and if it is a pull request event, don't do the publishing? |
@gep13 not really necessary to check the event name. It still wouldn't fix the error you saw, as it isn't considered a pull request since it is started on the repository branch itself, though. |
Ok, so now I am getting somewhere... I was looking at this PR: cake-contrib/Cake.Incubator#134 And the failing build took me through to this workflow: https://github.com/cake-contrib/Cake.Incubator/pull/134/checks?check_run_id=1990873969 But this takes me to the push event build, rather than the pull request event build. The pull request event build didn't actually run, it was skipped. The question that this leaves is that if I update the build configuration to limit builds to only master/develop/hotfix/release branches, will I still see the pull request event build? Going to need to play with this to confirm either way. I think it comes down to the fact that I personally don't want pre-release packages to be published as a result of a dependabot push/pull request event. I don't think I want to go as far as limiting publishing to the
|
If you remove the if statement, then yes the pull request would still build. |
Did some digging around in the code, and even if everything gets limited we still have something that needs to be updated in Cake.Recipe itself. The criteria for publishing don't take into account if the current build is a pull request or not: so this is probably something that should be updated. |
Yip, sounds like a change is indeed required. Thanks for digging into this. I think there used to be a check, so this is perhaps a regression. |
Yeah, either a regression or an oversight from back when we changed from only supporting AppVeyor to multiple build providers. |
🎉 This issue has been resolved in version 2.2.1 🎉 The release is available on: Your GitReleaseManager bot 📦🚀 |
* hotfix/2.2.1: (cake-contrib#811) Add cake-recipe tag to nuspec (cake-contrib#800) Add IsPullRequest criteria to tasks (cake-contribGH-793) error when vcsroot.branch is missing (cake-contribGH-801) Update to try pushing chocolatey packages on Windows platform (cake-contrib#805) Fix string formatting syntax
Some tasks are executed during a Pull Request build, when they shouldn't be.
For example, pushing packages to NuGet/Chocolatey feeds shouldn't happen when running on a PR build. The packages should be created, but they shouldn't be published anywhere.
The text was updated successfully, but these errors were encountered: