crossplane-contrib / crossplane-contrib/provider-upjet-github

Feature : Add requiredDeploymentEnvironments element in BranchProtection

Open
#187 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
56
Forks
46
Avg merge
6d 7h
Merged PRs (30d)
2

Description

# Feature Request: Add `requiredDeploymentEnvironments` to BranchProtection CRD

## Summary
Add support for requiring successful deployments to specific environments before allowing branch merges, similar to GitHub's "Require deployments to succeed before merging" feature.

## Background
GitHub's Branch Protection API supports requiring successful deployments to specific environments before merging. This is a critical feature for GitOps workflows where preview/staging deployments must succeed before merging to protected branches.

## Current Limitation
The current `BranchProtection` and `BranchProtectionv3` CRDs only support status checks as a workaround for deployment validation, but lack native support for deployment environment requirements.

## Proposed Solution
Add a `requiredDeploymentEnvironments` field to the `BranchProtection` CRD:

```yaml
apiVersion: repo.github.upbound.io/v1alpha1
kind: BranchProtection
spec:
forProvider:
pattern: dev
# ... existing fields ...
requiredDeploymentEnvironments:
- "preview"
- "staging"
```

## GitHub API Reference
This feature exists in GitHub's REST API:
- [[Branch Protection API](https://docs.github.com/en/rest/branches/branch-protection)](https://docs.github.com/en/rest/branches/branch-protection)
- The API supports `required_deployment_environments` parameter

Example API response structure:
```json
{
"required_deployment_environments": ["preview", "staging"]
}
```

## Use Case
Common GitOps workflow:
1. Developer creates PR against `dev` branch
2. CI builds and deploys to `preview` environment
3. Preview deployment must succeed before PR can be merged
4. This ensures broken deployments don't reach protected branches

## Current Workaround
Currently users must rely on status checks set by external systems (ArgoCD, etc.) rather than native GitHub deployment validation.

## Impact
- Improves GitOps workflow safety
- Aligns with GitHub's native deployment protection features
- Reduces reliance on external status check workarounds

## References
- GitHub Branch Protection API: https://docs.github.com/en/rest/branches/branch-protection
- Related Terraform provider implementation: https://registry.terraform.io/providers/integrations/github/latest/docs/resources/branch_protection

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.