From 1389abbdd172f689755468a50c41c4747aaccf2b Mon Sep 17 00:00:00 2001 From: Frank Scholter Peres Date: Fri, 24 Oct 2025 13:02:24 +0200 Subject: [PATCH 1/2] added copybara example workflow --- .../workflows/copybara/copy.bara.example.sky | 28 +++++++++ .github/workflows/copybara/copybara.yml | 61 +++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 .github/workflows/copybara/copy.bara.example.sky create mode 100644 .github/workflows/copybara/copybara.yml diff --git a/.github/workflows/copybara/copy.bara.example.sky b/.github/workflows/copybara/copy.bara.example.sky new file mode 100644 index 0000000..4387a31 --- /dev/null +++ b/.github/workflows/copybara/copy.bara.example.sky @@ -0,0 +1,28 @@ +# copy.bara.sky +sourceUrl = "https://internal.git" +sourceBranch = "main" + +destinationUrl = "https://open_source.git" +destinationBranch = "main" + +core.workflow( + name = "sync_to_open_source", + origin = git.origin( + url = sourceUrl, + ref = sourceBranch, + ), + + destination = git.github_pr_destination( + url = destinationUrl, + destination_ref = destinationBranch, + pr_branch = "{{PR_BRANCH}}", + title = "{{PR_TITLE}}", + body = "{{PR_BODY}}", + ), + origin_files = glob(["**"], exclude = [ ".github/**"]), + destination_files = glob(["**"], exclude = [".github/**"]), + authoring = authoring.pass_thru("Name "), + transformations = [ + # Add any transformations here if needed + ], +) diff --git a/.github/workflows/copybara/copybara.yml b/.github/workflows/copybara/copybara.yml new file mode 100644 index 0000000..7df7215 --- /dev/null +++ b/.github/workflows/copybara/copybara.yml @@ -0,0 +1,61 @@ +name: Copybara (manual with branch) + +on: + workflow_dispatch: + inputs: + pr_branch: + description: 'Name of the PR-Branch' + required: true + default: 'copybara-branch' + pr_title: + description: 'Title of the Pull Requests' + required: true + default: 'Copybara PR' + pr_body: + description: 'Description of the PR' + required: false + default: '---\n\nName , company' + +jobs: + run-copybara: + runs-on: [self-hosted, linux, x64] + env: + ENTERPRISE_GITHUB_API_URL: https://api.git.i.yourdomain.com + permissions: + contents: read + pull-requests: write + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: ${{ inputs.target_ref }} + persist-credentials: false + + # Copybara-JAR need Java 21+ + - name: Setup Java 21 + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: '21' + #example with internal enterprise git. Uses the forked version of copybara that supports enterprise git (https://github.com/google/copybara/pull/319) + - name: Run Copybara + env: + COPYBARA_CONF: 'your_local/copy.bara.sky' + run: | + git config --global user.name "git_user" + git config --global user.email "email_address" + + git config --global credential.helper 'store' + + printf 'https://x-access-token:%s@github.com\n' ${{ secrets.PAT_GITHUB }} >> "$HOME/.git-credentials" + printf 'https://x-access-token:%s@api.github.com\n' ${{ secrets.PAT_GITHUB }} >> "$HOME/.git-credentials" + printf 'https://x-acces-token:%s@$ENTERPRISE_GITHUB_API_URL\n' ${{ secrets.PAT_GITHUB_ENTERPRISE }} >> "$HOME/.git-credentials" + + sed -i "s|{{PR_BRANCH}}|${{ github.event.inputs.pr_branch }}|g" $COPYBARA_CONF + sed -i "s|{{PR_TITLE}}|${{ github.event.inputs.pr_title }}|g" $COPYBARA_CONF + sed -i "s|{{PR_BODY}}|${{ github.event.inputs.pr_body }}|g" $COPYBARA_CONF + + curl -LO https://github.com/qorix-group/copybara/releases/download/v20250508/copybara_deploy.jar + java -jar copybara_deploy.jar migrate $COPYBARA_CONF sync_to_open_source From 222301b84c3ccd755d299d3900f78be6ed6f041b Mon Sep 17 00:00:00 2001 From: Frank Scholter Peres Date: Fri, 24 Oct 2025 13:23:27 +0200 Subject: [PATCH 2/2] fix: fixed copyright --- .github/workflows/copybara/copy.bara.example.sky | 13 +++++++++++++ .github/workflows/copybara/copybara.yml | 13 +++++++++++++ 2 files changed, 26 insertions(+) diff --git a/.github/workflows/copybara/copy.bara.example.sky b/.github/workflows/copybara/copy.bara.example.sky index 4387a31..f33acb9 100644 --- a/.github/workflows/copybara/copy.bara.example.sky +++ b/.github/workflows/copybara/copy.bara.example.sky @@ -1,3 +1,16 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* + # copy.bara.sky sourceUrl = "https://internal.git" sourceBranch = "main" diff --git a/.github/workflows/copybara/copybara.yml b/.github/workflows/copybara/copybara.yml index 7df7215..0bd2f74 100644 --- a/.github/workflows/copybara/copybara.yml +++ b/.github/workflows/copybara/copybara.yml @@ -1,3 +1,16 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* + name: Copybara (manual with branch) on: