Implement a PR-based infrastructure workflow where all changes go through code review, automatic plans appear as comments, and merging triggers deployment.
Your team wants to:
This guide sets up a complete GitOps workflow with GitHub integration.
| Permission | Purpose |
|---|---|
| Read code | Clone repositories |
| Write pull requests | Post plan comments |
| Write commit status | Update check status |
| Read/write webhooks | Receive PR events |
| Setting | Recommended Value | Purpose |
|---|---|---|
| Default Branch | main | Where production code lives |
| Working Directory | / or /terraform | Path to Terraform files in repo |
| Auto-sync | Enabled | Pull changes from GitHub automatically |
If your ops0 project already has code, push it to GitHub:
main)If GitHub already has code, click Pull from GitHub instead.
Set up what happens when PRs are created:
terraform plan automatically when a PR is opened or updated.terraform apply when PR is merged. Enable with caution.To enforce the GitOps workflow, configure GitHub branch protection:
main branch| Setting | Value |
|---|---|
| Require pull request before merging | Yes |
| Required approvals | 1 (or more for production) |
| Require status checks | Yes |
| Required checks | ops0/terraform-plan, ops0/policy-check |
| Require branches to be up to date | Yes |
Let's verify everything works:
mainWithin 30-60 seconds:
✓ ops0/terraform-plan - Plan succeeded: 0 to add, 1 to change, 0 to destroy
✓ ops0/policy-check - All policies passed
### Terraform Plan
Changes: 0 to add, 1 to change, 0 to destroy
Cost Impact: +$0.00/month
~ aws_instance.web_server
~ tags.Environment: "dev" -> "development"
View full plan in ops0If you want changes to deploy automatically when PRs are merged:
main)For production environments, add a human checkpoint:
PR Merged
│
▼
Auto-plan runs
│
▼
Approval request sent (Slack/Email)
│
▼
Approver clicks "Approve" in ops0
│
▼
Terraform apply executes
│
▼
Result posted to PR/Slack
See Create Approval Workflows for setup details.
Once set up, here's how your team works:
| Check | Solution |
|---|---|
| GitHub App installed? | Verify in Settings > Integrations |
| Correct repository? | Confirm repo is connected in Project Settings |
| Webhooks working? | Check GitHub repo > Settings > Webhooks for delivery status |
| Working directory correct? | Ensure path matches where Terraform files are |
If ops0 and GitHub have diverged: