You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fixes: #2339
## Changes
- Automatically determine if HTTPS or SSH should be used based on the
remote URI
- SSH is configured via go-git transport using ssh-agent. Requires users
to upload their private keys to ssh-agent so that it can be picked up.
SSH-Agent is used so that the private key path + passphrase doesn't need
to passed in via env vars or flags.
## Result from running cloudtop
Command used: `librarian release init -push`. Resulted in PR created:
#2449
Logs from invocation:
```
level=INFO msg="Authenticating with SSH"
level=INFO msg="Successfully pushed changes"
level=INFO [msg="Creating PR" branch=librarian-20250926T172344Z base=main title="chore: librarian release pull request: 20250926T172344Z"](#2449)
level=INFO msg="PR created" url=#2449
level=INFO msg="Labels added to issue" number=2449 labels=[release:pending]
```
---------
Signed-off-by: Lawrence Qiu <[email protected]>
Copy file name to clipboardExpand all lines: README.md
+54-1Lines changed: 54 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -52,13 +52,66 @@ command to run the latest released version:
52
52
go run github.com/googleapis/librarian/cmd/librarian@latest -help
53
53
```
54
54
55
+
### Setup and Configuration
56
+
To run librarian, you will need to configure a Github Token and set it to the `LIBRARIAN_GITHUB_TOKEN` environment variable. This will use the Github token as authentication to push to Github and to run Github API commands (e.g. Creating a PR and Adding Labels to a PR).
57
+
58
+
Unless specifically configured, Librarian will use HTTPS for pushing to remote. See the [SSH](#using-ssh) section for push to remote via SSH.
59
+
60
+
### Github Token
61
+
There are two main options to get a Github token:
62
+
1. Use the [gh cli](https://cli.github.com/) tool to easily authenticate with github. Run the following commands once the tool is installed:
63
+
```shell
64
+
# Follow the instructions from the tool. If using SSH, see the section
65
+
# below regarding additional setup.You still need a Github Token to run
66
+
# Github API commands (e.g. creating a pull request).
67
+
gh auth login
68
+
# This will output the token to use as the Github Token
69
+
gh auth token
70
+
```
71
+
This will create a token with the `repo` scope.
72
+
73
+
2. Alternatively, follow the steps listed in the Github [guide](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-personal-access-token-classic) to create a Personal Access Token (PAT). You will need the `repo` scope for your token.
74
+
75
+
Once you have created a token, set the token as the environment variable:
76
+
```shell
77
+
export LIBRARIAN_GITHUB_TOKEN={YOUR_TOKEN_HERE}
78
+
```
79
+
80
+
### Using SSH
81
+
There are two main ways to configure SSH:
82
+
1. Using the [gh cli](https://cli.github.com/) to upload your SSH public key to Github. When following the steps in the gh cli tool, you will select your public key to be added to Github. Additionally, you will need to add your private key to the [ssh-agent](https://linux.die.net/man/1/ssh-agent).
83
+
84
+
Typically, your private keys will be `~/.ssh/id_ed25519` or `~/.ssh/id_rsa` and your public keys will be the same with the `.pub` suffix. You should be able to see this by running `ls ~/.ssh`. If you do not see a public/ private key combination, you can follow this [guide](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent) to generate a new key.
85
+
86
+
Running the following commands to add your private key to ssh-agent:
87
+
```sh
88
+
# This will start the ssh-agent if it hasn't already been started
89
+
eval"$(ssh-agent -s)"
90
+
91
+
# This adds your private key to the ssh-agent.
92
+
# Note: The private key will not have the `.pub` suffix.
93
+
ssh-add ~/.ssh/{PRIVATE_KEY_FILE}
94
+
95
+
# Run this command to verify that your private key is added
96
+
# You should see an output of a SHA with an absolute path to the private key
97
+
# e.g. `256 SHA:{MY_SHA} .../.ssh/id_ed25519`
98
+
ssh-add -l
99
+
```
100
+
101
+
2. Follow the steps [here](https://docs.github.com/en/authentication/connecting-to-github-with-ssh). You will need to either create a new SSH key or using an existing one, add it to the ssh-agent, and then upload it to Github.
102
+
103
+
Once everything has been configured, set the `origin` remote to the SSH URI:
0 commit comments