You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
modules/git-clone/README.md

2.7 KiB

display_name description icon maintainer_github verified tags
Git Clone Clone a Git repository by URL and skip if it exists. ../.icons/git.svg coder true
git
helper

Git Clone

This module allows you to automatically clone a repository by URL and skip if it exists in the base directory provided.

module "git-clone" {
  source   = "registry.coder.com/modules/git-clone/coder"
  version  = "1.0.2"
  agent_id = coder_agent.example.id
  url      = "https://github.com/coder/coder"
}

Examples

Custom Path

module "git-clone" {
  source   = "registry.coder.com/modules/git-clone/coder"
  version  = "1.0.2"
  agent_id = coder_agent.example.id
  url      = "https://github.com/coder/coder"
  base_dir = "~/projects/coder"
}

Git Authentication

To use with Git Authentication, add the provider by ID to your template:

module "git-clone" {
  source   = "registry.coder.com/modules/git-clone/coder"
  version  = "1.0.2"
  agent_id = coder_agent.example.id
  url      = "https://github.com/coder/coder"
}

data "coder_git_auth" "github" {
  id = "github"
}

GitHub clone with branch name

To GitHub clone with a specific branch like feat/example

# Prompt the user for the git repo URL
data "coder_parameter" "git_repo" {
  name         = "git_repo"
  display_name = "Git repository"
  default      = "https://github.com/coder/coder/tree/feat/example"
}

module "git-clone" {
  source   = "registry.coder.com/modules/git-clone/coder"
  version  = "1.0.11"
  agent_id = coder_agent.example.id
  url      = data.coder_parameter.git_repo.value
}

Configuring git-clone for a self-hosted GitHub Enterprise Server running at github.example.com

module "git-clone" {
  source   = "registry.coder.com/modules/git-clone/coder"
  version  = "1.0.11"
  agent_id = coder_agent.example.id
  url      = "https://github.example.com/coder/coder/tree/feat/example"
  git_providers = {
    "https://github.example.com/" = {
      tree_path = "github"
    }
  }
}

GitLab clone with branch name

To GitLab clone with a specific branch like feat/example

module "git-clone" {
  source   = "registry.coder.com/modules/git-clone/coder"
  version  = "1.0.11"
  agent_id = coder_agent.example.id
  url      = "https://gitlab.com/coder/coder/-/tree/feat/example"
}

Configuring git-clone for a self-hosted GitLab running at gitlab.example.com

module "git-clone" {
  source   = "registry.coder.com/modules/git-clone/coder"
  version  = "1.0.11"
  agent_id = coder_agent.example.id
  url      = "https://gitlab.example.com/coder/coder/-/tree/feat/example"
  git_providers = {
    "https://gitlab.example.com/" = {
      tree_path = "gitlab"
    }
  }
}