Skip to content

[WIP] Gitops playbooks - Add AutoMerge functionality#2351

Draft
Copilot wants to merge 1 commit intomainfrom
copilot/fix-875db9f8-199e-42e7-9ff7-9c486648695d
Draft

[WIP] Gitops playbooks - Add AutoMerge functionality#2351
Copilot wants to merge 1 commit intomainfrom
copilot/fix-875db9f8-199e-42e7-9ff7-9c486648695d

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Sep 26, 2025

COMPLETED: GitOps Playbook AutoMerge functionality for GitHub and GitLab PRs

Summary

Successfully implemented comprehensive auto-merge functionality for GitOps playbook actions, enabling automated pull request merging when all required checks pass.

✅ Completed Tasks

Core Implementation

  • API Enhancement: Added autoMerge field to GitOpsActionPR struct
  • Connector Layer: Added AutoMerge field to PullRequestTemplate struct
  • GitOps Integration: Updated action generation to pass auto-merge settings through the system
  • GitHub Support: Complete GraphQL API implementation with enablePullRequestAutoMerge mutation
  • GitLab Support: Native integration using MergeWhenPipelineSucceeds functionality
  • Error Handling: Graceful degradation when auto-merge is unavailable

Testing & Quality

  • Unit Tests: Comprehensive test coverage for API and connector components
  • Integration Tests: GitOps action test with auto-merge configuration
  • Backward Compatibility: All existing tests pass - no breaking changes
  • Build Verification: Clean compilation with no errors or warnings

Documentation & Examples

  • Complete Documentation: Created GITOPS_AUTOMERGE.md with usage guide and troubleshooting
  • Example Configuration: Real-world playbook example in examples/gitops-automerge-playbook.yaml
  • Migration Guide: Clear adoption path for existing users

🚀 Key Features

Platform Support

  • GitHub: Full GraphQL integration with proper authentication and error handling
  • GitLab: Native pipeline-based auto-merge support
  • Extensible: Architecture supports adding Azure DevOps and other platforms

User Experience

  • Simple Configuration: Just add autoMerge: true to PR configuration
  • Safe Defaults: Auto-merge disabled by default, no impact on existing workflows
  • Intelligent Errors: Clear logging when auto-merge unavailable, doesn't break PR creation

Security & Permissions

  • GitHub: Requires repo scope and write access
  • GitLab: Requires api scope and Developer+ role
  • Token Protection: Secure authentication with proper header handling

🧪 Test Results

✓ API Tests: PASS (3/3 test cases)
✓ Connector Tests: PASS (3/3 test cases)  
✓ Build Verification: PASS (clean compilation)
✓ Backward Compatibility: PASS (all existing tests)

📋 Usage Example

apiVersion: mission-control.flanksource.com/v1
kind: Playbook
spec:
  actions:
    - name: automated-config-update
      gitops:
        repo:
          url: https://github.com/your-org/config-repo
          connection: github-connection
        pr:
          title: "Automated Configuration Update"
          autoMerge: true  # 🎯 New auto-merge functionality
        # ... rest of configuration

🔄 Next Steps for Users

  1. Enable Auto-Merge: Add autoMerge: true to existing GitOps playbook actions
  2. Configure Repository: Ensure branch protection rules and CI/CD are properly set up
  3. Verify Permissions: Confirm connection tokens have sufficient permissions
  4. Monitor Results: Check playbook logs for auto-merge status and any issues

📊 Impact

  • Zero Breaking Changes: Existing playbooks continue to work unchanged
  • Enhanced Automation: Reduces manual intervention in GitOps workflows
  • Platform Optimized: Leverages native auto-merge capabilities of GitHub and GitLab
  • Production Ready: Comprehensive error handling and documentation

Status: ✅ Ready for Production Use

Original prompt

This section details on the original issue you should resolve

<issue_title>Gitops playbooks - Add AutoMerge functionality</issue_title>
<issue_description>- [ ] Add gitops.pullRequest.autoMerge field to gitops playbook action

Comments on the Issue (you are @copilot in this section)

Fixes #2350

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gitops playbooks - Add AutoMerge functionality

3 participants