terraform-provider-github icon indicating copy to clipboard operation
terraform-provider-github copied to clipboard

Actions: Self-hosted runner

Open rjudin opened this issue 4 years ago • 11 comments

Thanks to https://github.com/github/roadmap/issues/73 we can create GithubAction groups with self-hosted runners

Expected Behavior

Define self-hosted runners in terraform, based on API ref [1]

Actual Behavior

lack of this possibility [1]

Steps to Reproduce

  1. create new Github Org
  2. go to https://github.com/organizations/MY_ORG/settings/actions and add a new group image by specifying repo scope
  3. Add a new runner with labels to this group [2]
  4. Execute Action with this group [3]

Proposed resources:

# add group [4]
github_actions_runner_group "dev" {
  description             = "DEV self-hosted runner group"
  name                    = "dev-runners"
  visibility              = "all" #all, selected, or private
  selected_repository_ids = ["repo1.id", "repo2.id"]
  runners                 = [runner1.id, runner2.id] # optional
}

github_actions_runner "dev_win" {
  description = "DEV self-hosted runners with Windows"
  name        = "dev-runners-win"
  labels      = ["dev", "win"]
}

resource "kubernetes_deployment" "dev_win" {
  ...
  env {
    GH_TOKEN = github_actions_runner.dev_win.token
  }
}

References

[1] https://docs.github.com/en/rest/reference/actions [2] https://docs.github.com/en/actions/hosting-your-own-runners/adding-self-hosted-runners [3] https://docs.github.com/en/actions/hosting-your-own-runners/using-self-hosted-runners-in-a-workflow [4] https://docs.github.com/en/rest/reference/actions#create-a-self-hosted-runner-group-for-an-organization

rjudin avatar Sep 01 '20 13:09 rjudin