Skip to content

programmfabrik/terraform-hetzner-github-actions

Repository files navigation

terraform-hetzner-github-actions

This repository provides the functionality to deploy the github actions runner on the hetzner cloud infrastructure. This repository is used to set up the test infrastructure for the fylr application.

Example terraform.tfvars, which provides the runners at repository level

hcloud_token="<my-hcloud-token>"

hetzner_machine_type="cx21"
hetzner_machine_os="debian-10"
hetzner_additional_public_key_ids=["username@local-system"]
hetzner_machine_additional_packages=""

github_actions_runner_labels="example"
github_actions_runner_replace_existing=false
github_actions_runner_count=3

github_owner="example-repo-owner"
github_repository_name="example-repo-name"
github_authentication_user="example-bot"
github_authentication_token="<example-bot personal access token>"

ssh_key_name="example-bot-ssh-key"

Example terraform.tfvars, which provides the runners at organisation level

hcloud_token="<my-hcloud-token>"

hetzner_machine_type="cpx21"
hetzner_machine_os="debian-10"
# one of the keys in the hcloud project
hetzner_additional_public_key_ids=["username@local-system"]
# not needed for runner
hetzner_machine_additional_packages=""

# comma separated list
github_actions_runner_labels="example"
github_actions_runner_replace_existing=false
github_actions_runner_count=3

github_owner="programmfabrik"
github_authentication_user="example-bot"
github_authentication_token="<example-bot personal access token>"

# not part of hetzner_additional_public_key_ids, see explanation above
ssh_key_name="example-bot-ssh-key"

github_runner_type="org"

Requirements

Name Version
terraform >= v1.2.9
hcloud >= 1.35.1

Providers

Name Version
hcloud 1.35.1

Modules

Name Source Version
hetzner_gh_runners ./modules/actions-runner n/a

Resources

Name Type
hcloud_ssh_key.admin_ssh_key resource

Inputs

Name Description Type Default Required
github_actions_runner_count Defines the number of runners to be provided. This option is equal to Machines at hetzner. number 1 no
github_actions_runner_labels Defines a list of labels used to identify the runners. The list is divided by separating the individual entries with ,. string "" no
github_actions_runner_replace_existing Specifies whether to replace existing Github action runners with the same name. bool false no
github_authentication_token Sets the personal access token for the configured user in the variable github_authentication_user. string n/a yes
github_authentication_user Sets the user used for issuing new registration tokens. Ensure that the user has the appropriate permissions. string n/a yes
github_owner Defines the organisation name or repository owner. string "" no
github_repository_name Sets the name of the repository. This option is only used if you use self-hosted Github runners at the repository level. string "" no
github_runner_release Defines the version of the github runner to be installed. The version must be specified in the format 2.277.1. string "2.298.1" no
github_runner_type Defines the github runner type. Available values are: repo, org string "repo" no
hcloud_token Hetzner Cloud API token string n/a yes
hetzner_additional_public_key_ids Adds public keys to the server that are already registered at hetzner list(string) [] no
hetzner_ip_config Defines the IP configuration for the machine. The IP configuration is used to assign a static IP address to the machine.
object({
ipv4_enabled = bool
ipv6_enabled = bool
})
{
"ipv4_enabled": true,
"ipv6_enabled": true
}
no
hetzner_machine_additional_packages Defines additional packages that must be installed on the machine. Each package name must be separated by a space . string "" no
hetzner_machine_location Specifies the location of the data center where the machine is to be deployed. string "nbg1" no
hetzner_machine_os Defines the machine operating system to be installed. string "debian-10" no
hetzner_machine_type Sets the machine type to use. string "cx11" no
ssh_key_name Defines the name for the ssh key string "admin_ssh_key" no
ssh_private_key Defines the path to the location of the private key. The private key is used together with the public key to connect to the machine. string "~/.ssh/id_rsa" no
ssh_public_key Public Key to authorized the access to the machines string "~/.ssh/id_rsa.pub" no
ssh_username Username that should be used to connect to the nodes string "root" no

Outputs

Name Description
runner_ipv4_addresses n/a
runner_ipv6_addresses n/a
runner_machine_names n/a