google / google/copybara

Passing a Variable to copybara.sky in Dockerized Copybara

Open
#264 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
3.8k
Forks
345
PR merge metrics
No merged PRs in 30d

Description

Hello,

I'm currently working on synchronizing two repositories (from repoA to repoB) using Copybara running in a Docker container. Below is the command I'm using to initiate the sync process:
```
docker_cmd = [
"docker run", "-v ~/.ssh:/root/.ssh", "-v ~/mongodb-bot.gitconfig:/root/.gitconfig",
f'-v "{current_dir}/copybara.sky":/usr/src/app/copy.bara.sky',
"-e COPYBARA_CONFIG='copy.bara.sky'", "-e COPYBARA_SUBCOMMAND='migrate'",
"-e COPYBARA_OPTIONS='-v'", "copybara copybara"
]
```
I've noticed that the name and email from ~/mongodb-bot.gitconfig are being utilized correctly during the sync to repoB. However, now I need to pass a GitHub Apps token to the destinationUrl in my copybara.sky configuration file.

I have tried hardcoding the token directly in the URL like this:

python
`destinationUrl = "https://x-access-token:@github.com/xxx/xx.git"`
And it works as expected. However, for security and flexibility reasons, I'd like to pass the token from my Python script to the copybara.sky file instead of hardcoding it.

I have tried to add it to my .gitconfig file like below, but it does not work.
```
[http]
extraheader = x-access-token:{token}
```

Is there a way to pass a variable (in this case, the GitHub Apps token) from my Python environment to the copybara.sky file? If so, could you please guide me on how to achieve this?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.