Skip to content

Commit 8419123

Browse files
committed
[rules_mc] 添加 rules_mc 的 copybara 配置
1 parent 8b57f6e commit 8419123

File tree

5 files changed

+91
-0
lines changed

5 files changed

+91
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Sync rules_mc to GitHub
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- 'rules_mc/**'
9+
workflow_dispatch:
10+
inputs:
11+
flags:
12+
description: Flags to be passed to Copybara
13+
required: false
14+
default: ""
15+
type: string
16+
17+
jobs:
18+
sync:
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Checkout monorepo
23+
uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
27+
- name: Set up JDK 21
28+
uses: actions/setup-java@v3
29+
with:
30+
java-version: '21'
31+
distribution: 'temurin'
32+
33+
- name: Setup Android SDK
34+
uses: android-actions/setup-android@v3
35+
36+
- uses: nttld/setup-ndk@v1
37+
id: setup-ndk
38+
with:
39+
ndk-version: r28b
40+
41+
- name: Setup Bazel
42+
uses: bazel-contrib/setup-bazel@0.14.0
43+
44+
- name: Run Copybara sync
45+
env:
46+
COPYBARA_RULES_MC_TOKEN: ${{ secrets.COPYBARA_RULES_MC_TOKEN }}
47+
FLAGS: ${{ inputs.flags }}
48+
run: |
49+
git config --global user.name Copybara
50+
git config --global user.email copybara@copybara
51+
git config --global credential.helper store
52+
echo "https://x-access-token:${{ secrets.COPYBARA_RULES_MC_TOKEN }}@github.com" > ~/.git-credentials
53+
bazel run --run_under="cd $PWD &&" //copybara -- copybara/copy.bara.sky rules_mc $FLAGS

MODULE.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ include("//module:android.MODULE.bazel")
101101
# tools
102102
include("//module:mdbook.MODULE.bazel")
103103

104+
include("//module:copybara.MODULE.bazel")
105+
104106
# rules
105107
include("//module:rules.MODULE.bazel")
106108

copybara/BUILD.bazel

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
load("@rules_java//java:java_binary.bzl", "java_binary")
2+
3+
java_binary(
4+
name = "copybara",
5+
main_class = "com.google.copybara.Main",
6+
runtime_deps = ["@com_github_google_copybara//jar"],
7+
)

copybara/copy.bara.sky

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
core.workflow(
2+
name = "rules_mc",
3+
origin = git.origin(
4+
url = "https://github.com/TouchController/TouchController-Monorepo.git",
5+
ref = "master",
6+
),
7+
destination = git.github_destination(
8+
url = "https://github.com/TouchController/rules_mc.git",
9+
),
10+
authoring = authoring.pass_thru("Copybara <copybara@copybara>"),
11+
origin_files = glob(["rules_mc/**"]),
12+
transformations = [
13+
core.move(
14+
"rules_mc",
15+
"",
16+
overwrite = True,
17+
),
18+
],
19+
mode = "ITERATIVE",
20+
set_rev_id = True,
21+
)

module/copybara.MODULE.bazel

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
"""Module extension to download Copybara."""
2+
3+
http_jar = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_jar")
4+
http_jar(
5+
name = "com_github_google_copybara",
6+
sha256 = "d1a43707446e1335a9cb015769e55d086a1954ee2abd0f8bf8187b4b5566241f",
7+
url = "https://github.com/google/copybara/releases/download/v20260119/copybara_deploy.jar",
8+
)

0 commit comments

Comments
 (0)