-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathcopy.bara.sky.ts
75 lines (71 loc) · 2.2 KB
/
copy.bara.sky.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
export const copyBaraSky = (
sotRepo: string,
sotBranch: string,
destinationRepo: string,
destinationBranch: string,
committer: string,
localSot: string,
pushInclude: string,
pushExclude: string,
pushTransformations: string,
prInclude: string,
prExclude: string,
prTransformations: string
) => `
# Variables
SOT_REPO = "${sotRepo}"
SOT_BRANCH = "${sotBranch}"
DESTINATION_REPO = "${destinationRepo}"
DESTINATION_BRANCH = "${destinationBranch}"
COMMITTER = "${committer}"
LOCAL_SOT = "${localSot}"
PUSH_INCLUDE = [${pushInclude}]
PUSH_EXCLUDE = [${pushExclude}]
PUSH_TRANSFORMATIONS = [${pushTransformations}
]
PR_INCLUDE = [${prInclude}]
PR_EXCLUDE = [${prExclude}]
PR_TRANSFORMATIONS = [${prTransformations}
]
# 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),
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),
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("[email protected]:", " ").replace(".git", "#")),
] + PR_TRANSFORMATIONS,
)
`;