Disable builds for Draft PRs (GitHub)

I don’t want Netlify builds triggered on draft PRs since we will have a number of these open with many of them not necessarily going anywhere. Is this possible?

I found this thread from 2019 which offered little to no help: Don't build/deploy site when the PullRequest is in Draft - #2 by fool

Three years later, has anything changed? How would I implement the suggested “detect a draft PR” in that thread? I’m not interested in adding additional/unneeded information to our commits that is prone to human error.

I’d suggest the same thing I did 3 years ago: write an ignore script (File-based configuration | Netlify Docs). Could you let me know what is wrong with that suggestion? You’ll have to code it, but it is 100% possible since you can do things like git status to show the PR details in the script :slight_smile:

How do I use git status to get information about the pull request on GitHub? My understanding is this command could only reveal information in git not GitHub?

I have several custom ignore scripts that we use in the monorepo to detect when a particular package should deploy, so I am reasonably familiar with creating these scripts but I don’t understand how I can use the git CLI to gather information about the pull request on GH aside from filesystem changes which does not tell me what I need.

It looks like this is available via the GH api so in theory I could write something to make an API request to the GH api for a given PR using the $REVIEW_ID env var, but I feel like this really should be Netlify’s responsibility since this information is available via PR webhooks on the pull_request object and then it should be exposed in it’s own ENV var.

Ah, I am surprised to hear that you need to query github to get this detail :frowning: - I figured that it was present in plain git log since we clone your repo fully to our systems. If that’s true, I guess my best advice would be to use some feature that is more detectable via git log to mark deploys as draft, then (certainly you could use API calls during the script, but that starts to sound fragile)…

I think the idea of a “draft” pull request (and possibly even a pull request in general?) is part of GitHub and not git so I don’t believe there would be a way to obtain this information without communicating with GH. I would also prefer to not use build minutes on network requests and additionally it would be fragile as you mentioned. is there anywhere I can request this feature?

As I said, I am not interesting in relying on people marking commits in a way that they shouldn’t be deployed. This also would not work with drafts as once someone moved a PR from draft to ready for review, there would be no change in the commits and the commits would still be marked as “no deploy”

Your request here is sufficient. I can tell you it is very unlikely we’d build it since you are the only one ever to ask for it, though, so you’d do better to work around it or to use some platform other than Netlify if you can’t figure out a good way to do so.

I am certain there are other ways you could accomplish this goal, albeit probably not using the exact draft deploys feature.