Auto-Clone GitHub Repo on Workspace Creation (with GitHub Auth)
Request:
Add support for automatically cloning a GitHub repository (including private repos) when a new workspace is created, if the user authenticated with GitHub.
Details:
- Use the user's GitHub token from OAuth to clone the repo.
- Allow specifying the repo URL, branch, and target directory in the workspace template or
coder.yaml
.
- Optionally support running an initialization script after cloning (e.g., pnpm install
, start dev server).
Stretch Goal:
Support cloning multiple repositories into the workspace with separate paths and branches defined per repo.
Why it matters:
This would streamline onboarding and setup, ensuring all developers start with the correct codebase and configuration without manual steps.2 Replies
HI @Jason Overmier Have you seen https://registry.coder.com?
You can use the following module to clone repos.
https://registry.coder.com/modules/coder/git-clone
And to run a script. You can add something in
startup_script
See an example here: https://github.com/coder/coder/blob/7b06fc77ae4bf5a9a52c3e750ec580dcb8e2437f/dogfood/coder/main.tf#L499GitHub
coder/dogfood/coder/main.tf at 7b06fc77ae4bf5a9a52c3e750ec580dcb8e2...
Secure environments for developers and their agents - coder/coder
I was able to get this working. Thanks for the doc reference!