Origins & Destinations Overview
Origins & Destinations
Section titled “Origins & Destinations”Copybara’s architecture is based on origins (where code comes from) and destinations (where code goes to).
Architecture
Section titled “Architecture”Available Origins
Section titled “Available Origins”| Origin | Description | Use Case |
|---|---|---|
git.origin | Generic Git repository | Any Git repo |
git.github_origin | GitHub with API integration | GitHub repos |
git.github_pr_origin | GitHub pull requests | Importing PRs |
git.gerrit_origin | Gerrit with CL integration | Gerrit repos |
git.github_trigger | GitHub events | Feedback workflows |
folder.origin | Local filesystem | Testing, local ops |
Available Destinations
Section titled “Available Destinations”| Destination | Behavior | Use Case |
|---|---|---|
git.destination | Push to branch | Direct sync |
git.github_destination | Push to GitHub | GitHub repos |
git.github_pr_destination | Create GitHub PRs | PR-based sync |
git.gerrit_destination | Create Gerrit CLs | Gerrit repos |
git.github_api | GitHub API actions | Feedback workflows |
folder.destination | Local filesystem | Testing, preview |
Choosing an Origin
Section titled “Choosing an Origin”For Regular Syncs
Section titled “For Regular Syncs”# Generic Gitorigin = git.origin( url = "https://github.com/org/repo", ref = "main",)
# GitHub with extra featuresorigin = git.github_origin( url = "https://github.com/org/repo", ref = "main",)For Importing PRs
Section titled “For Importing PRs”origin = git.github_pr_origin( url = "https://github.com/org/repo", branch = "main",)For Testing
Section titled “For Testing”origin = folder.origin()Choosing a Destination
Section titled “Choosing a Destination”Direct Push
Section titled “Direct Push”destination = git.destination( url = "https://github.com/org/repo", push = "main",)Create PRs
Section titled “Create PRs”destination = git.github_pr_destination( url = "https://github.com/org/repo", destination_ref = "main",)Create Gerrit CLs
Section titled “Create Gerrit CLs”destination = git.gerrit_destination( url = "https://gerrit.example.com/repo", push_to_refs_for = "main",)Testing Locally
Section titled “Testing Locally”destination = folder.destination()Common Patterns
Section titled “Common Patterns”Internal → GitHub (Open Sourcing)
Section titled “Internal → GitHub (Open Sourcing)”origin = git.origin(url = internal_url, ref = "main")destination = git.github_destination(url = github_url, push = "main")GitHub → Internal (Importing)
Section titled “GitHub → Internal (Importing)”origin = git.github_pr_origin(url = github_url, branch = "main")destination = git.gerrit_destination(url = internal_url, ...)Internal → GitHub via PR
Section titled “Internal → GitHub via PR”origin = git.origin(url = internal_url, ref = "main")destination = git.github_pr_destination(url = github_url, destination_ref = "main")Local Testing
Section titled “Local Testing”origin = folder.origin()destination = folder.destination()Authentication
Section titled “Authentication”See Authentication guide for details on:
- Personal Access Tokens
- SSH keys
- Deploy keys
- Fine-grained tokens