Skip to content
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

Do not run plan on draft PRs #1195

Open
ZIJ opened this issue Feb 22, 2024 · 1 comment
Open

Do not run plan on draft PRs #1195

ZIJ opened this issue Feb 22, 2024 · 1 comment

Comments

@ZIJ
Copy link
Contributor

ZIJ commented Feb 22, 2024

Planning on every commit in draft PRs before they are marked as ready for review is not economical, and noisy.

We have a lot of PRs created as Drafts, especially dependabot/renovate PRs that often get a lot of pushed before anyone even looks at them. Before they are in the "ready to review" state we have no need to run any TF plans on them. In atlantis we can set allowDraftPRs: false, but Github Actions has no trigger that allows this restriction. So for every push on such a Draft-PR a runner would have to pick up a digger job, just to check for if: github.event.pull_request.draft == 'false' and exit. Regarding the amount of Draft PRs we have and how often dependabot/renovate push, this is not economical.

Potential solution

have an allowDraftPRs option just like Atlantis. If set to true , orchestrator will only trigger on the ready_for_review event

@norman-zon
Copy link
Contributor

Nice to see progress on this! Thanks a lot.

One idea, that for sure exceeds this use case, how to implement this (and much more) would be to run OPA policies against the Github payload, as spacelift.io does.

There it is possible to write the no-draft-PR constraint in rego like this:

package spacelift

# Track runs for pushes to the tracked branch
track {
 input.push.branch == input.stack.branch
}

# Propose runs for pull requests to the tracked branch
propose {
 not is_null(input.pull_request)
 input.pull_request.branch == input.stack.branch
}

# Ignore pull requests that are drafts
ignore {
 not is_null(input.pull_request)
 input.pull_request.draft == true
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants