Give a workstation access to GitHub
Clone and push a private GitHub repository from a workstation with git, using a personal access token that no program on the workstation can read.
Clone and push a private GitHub repository from a workstation with git, using a personal
access token that no program on the workstation can read. Ringleader adds the token to
requests for GitHub as they leave the workstation, so the workstation never holds it. Use
this when you want your code, or your coding agent’s work, in a repository you own.
Prerequisites
- Ringleader installed, with the Ringleader application running.
- A running workstation on your computer, labeled
role: agent. The examples use a workstation namedmy-git-box; replace it with yours. To create one, follow the Quickstart and use your own name. Then runrl workstation label my-git-box role=agent -n local. A cloud workstation needs an Edge, as Providers and where the key is added describes, so this guide is for a workstation on your computer. - A GitHub personal access token that can read and write the repository.
Add your token and Git identity
Store the token in a Secret, then apply one file. The file adds the token to every
workstation with the label. It also installs git and sets the name and email on your
commits.
Store the token in a Secret named
github-pat:rl secret create github-pat -n local --from-string token=<your-token>Save this as
my-git.yaml, with your own name and email. The Integration holds the token. The WorkstationConfig installsgitand writes your identity:apiVersion: workstations.ringleader.dev/v1 kind: Integration metadata: name: my-github namespace: local spec: type: httpProxy selector: matchLabels: role: agent httpProxy: vendor: github credentialRef: name: github-pat key: token --- apiVersion: workstations.ringleader.dev/v1 kind: WorkstationConfig metadata: name: my-git-identity namespace: local spec: selector: matchLabels: role: agent devtools: - name: git toolconfigs: - id: git name: git config: userName: Your Name userEmail: you@example.comThe workstation can use your token
Every program in the workstation, your coding agent included, can use GitHub with the access your token has, though none can read the token. Create a token that reaches only the repositories you need, and keep the Integration behind a label, as this file does.Apply the file. It reaches the workstations that carry the label now and the ones you create later:
rl apply -f my-git.yamlWait until the workstation has applied it:
rl workstation wait my-git-box --for Configured --timeout 10m -n localThe command returns once the workstation’s
Configuredcondition isTrue.
Clone and push a private repository
Clone the repository, commit a change and push it from the workstation’s shell over HTTPS, with no password prompt.
Open a shell on the workstation:
rl shell my-git-box -n localClone your repository. The clone finishes without asking for a password:
git clone https://github.com/your-org/your-app.gitChange into the repository’s folder:
cd your-appCreate a file to commit, since a fresh clone has no changes:
echo "test" >> push-test.txtStage the file:
git add push-test.txtCommit the file. The commit carries your name and email:
git commit -m "Try a push from my workstation"Push the commit. The push finishes without asking for a password:
git push
Troubleshoot
- If the clone fails with an authentication error, check that the Integration reached the
workstation. Run
rl workstation get-resolved-configuration my-git-box -n localand look forintegration-my-githubunderappliedConfigs. If it’s missing, the workstation doesn’t carry the labelrole: agent.
Next steps
- Injected credentials explains how Ringleader adds the token outside the workstation, and where it works.
- Connect your GitHub account gets a short-lived token for you, so you don’t create or rotate a token.
- Use several GitHub identities on one workstation adds a second token, such as a bot account’s, and chooses which one each request uses.
- SSH keys for outbound Git clones over SSH with a key from your computer, and says what that costs.
- Create a front-end workstation builds a workstation for front-end work, with your own project on it.