mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
docs: git auth via template (#6850)
This commit is contained in:
@@ -90,3 +90,35 @@ To support regex matching for paths (e.g. github.com/orgname), you'll need to ad
|
||||
```console
|
||||
git config --global credential.useHttpPath true
|
||||
```
|
||||
|
||||
## Require git authentication in templates
|
||||
|
||||
If your template requires git authentication (e.g. running `git clone` in the [startup_script](https://registry.terraform.io/providers/coder/coder/latest/docs/resources/agent#startup_script)), you can require users authenticate via git prior to creating a workspace:
|
||||
|
||||

|
||||
|
||||
The following example will require users authenticate via GitHub and auto-clone a repo
|
||||
into the `~/coder` directory.
|
||||
|
||||
```hcl
|
||||
data "coder_git_auth" "github" {
|
||||
# Matches the ID of the git auth provider in Coder.
|
||||
id = "github"
|
||||
}
|
||||
|
||||
resource "coder_agent" "dev" {
|
||||
os = "linux"
|
||||
arch = "amd64"
|
||||
dir = "~/coder"
|
||||
env = {
|
||||
GITHUB_TOKEN : data.coder_git_auth.github.access_token
|
||||
}
|
||||
startup_script = <<EOF
|
||||
if [ ! -d ~/coder ]; then
|
||||
git clone https://github.com/coder/coder
|
||||
fi
|
||||
EOF
|
||||
}
|
||||
```
|
||||
|
||||
See the [Terraform provider documentation](https://registry.terraform.io/providers/coder/coder/latest/docs/data-sources/git_auth) for all available options.
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 279 KiB |
Reference in New Issue
Block a user