New Copybara Github Action & Docker image
- Dominant language
- Java
- Stars
- 3.8k
- Forks
- 345
- PR merge metrics
- No merged PRs in 30d
Description
Hey guys,
Thank you for the great work with Copybara. I recently learnt about it and decided to create a [Copybara GitHub Action](https://github.com/olivr/copybara-action) to make it really easy to use with as little config as possible.
It can be dropped in any GitHub repo and will work out of the box for GitHub <=> GitHub.
My action's repo is also building nightly a [Copybara Docker image](https://hub.docker.com/r/olivr/copybara) straight from the official repo (google/copybara). Check out the source [here](https://github.com/olivr/copybara-action/blob/main/.github/workflows/copybara-docker.yml).
Here is the copy.bara.sky I am using [as a template](https://github.com/olivr/copybara-action/blob/main/src/copy.bara.sky.ts) under the hood. Any advice on how to improve it is more than welcome:
```sky
# Variables
SOT_REPO = "git@github.com:olivr/copybara-action.git"
SOT_BRANCH = "main"
DESTINATION_REPO = "git@github.com:olivr/copybara-action-test.git"
DESTINATION_BRANCH = "main"
COMMITTER = "Github Actions "
LOCAL_SOT = "file:///usr/src/app"
push_include = ["**"]
PUSH_EXCLUDE_FILES = []
PUSH_TRANSFORMATIONS = []
pr_include = ["**"]
pr_exclude = []
PR_TRANSFORMATIONS = []
# Push workflow
core.workflow(
name = "push",
origin = git.origin(
url = LOCAL_SOT if LOCAL_SOT else SOT_REPO,
ref = SOT_BRANCH,
),
destination = git.github_destination(
url = DESTINATION_REPO,
push = DESTINATION_BRANCH,
),
origin_files = glob(push_include, exclude = PUSH_EXCLUDE_FILES),
authoring = authoring.pass_thru(default = COMMITTER),
mode = "ITERATIVE",
transformations = [
metadata.restore_author("ORIGINAL_AUTHOR", search_all_changes = True),
metadata.expose_label("COPYBARA_INTEGRATE_REVIEW"),
] + PUSH_TRANSFORMATIONS if PUSH_TRANSFORMATIONS else core.reverse(PR_TRANSFORMATIONS),
)
# Pull Request workflow
core.workflow(
name = "pr",
origin = git.github_pr_origin(
url = DESTINATION_REPO,
branch = DESTINATION_BRANCH,
),
destination = git.github_pr_destination(
url = SOT_REPO,
destination_ref = SOT_BRANCH,
integrates = [],
),
destination_files = glob(push_include, exclude = PUSH_EXCLUDE_FILES),
origin_files = glob(pr_include if pr_include else ["**"], exclude = pr_exclude),
authoring = authoring.pass_thru(default = COMMITTER),
mode = "CHANGE_REQUEST",
set_rev_id = False,
transformations = [
metadata.save_author("ORIGINAL_AUTHOR"),
metadata.expose_label("GITHUB_PR_NUMBER", new_name = "Closes", separator = DESTINATION_REPO.replace("git@github.com:", " ").replace(".git", "#")),
] + PR_TRANSFORMATIONS,
)
```
It is using a common flow:
```text
Source of Truth Destination
+---------------+ Copybara +---------------+
| Branch +------------> | Branch |
+-------+-------+ +---------------+
^
|
|
+-------+-------+ Copybara +---------------+
| Pull Requests | <------------+ Pull Requests |
+---------------+ +---------------+
```
I believe it would be helpful to add this template to your documentation and add a link to my GitHub Action, but I don't want to appear like I am self-promoting, if you agree please just let me know and I'll create a PR.
Contributor guide
Assessment
This issue has not been assessed yet.