Skip to content

Commit

Permalink
fix(github-runner): redesign the nomad job template to use different …
Browse files Browse the repository at this point in the history
…orgs

Provide different job names and group names

Signed-off-by: Bruce Becker <[email protected]>
  • Loading branch information
brucellino committed Oct 24, 2023
1 parent da735ce commit 1a22d56
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 31 deletions.
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ repos:
args:
- fmt
files: nomad
exclude: ".*tpl"

ci:
autoupdate_branch: main
70 changes: 39 additions & 31 deletions github-runner/github-runner.nomad.tpl
Original file line number Diff line number Diff line change
@@ -1,60 +1,68 @@
variable "runner_version" {
description = "Version to use for the github runner.\nSee https://github.com/actions/runner/releases/"
default = "2.303.0"
type = string
}

// variable "github_org" {
// description = "Name of the github org we attach the runner to"
// default = "SouthAfricaDigitalScience"
// type = string
// }
job "github-runner" {
job "github-runner-${org}" {
name = "github-runner-${org}"
datacenters = ["dc1"]
group "main" {
task "dependencies" {
driver = "exec"
artifact {
source = "https://github.com/actions/runner/releases/download/v${runner_version}/actions-runner-linux-arm64-${runner_version}.tar.gz"
}
config {
command = "./bin/installdependencies.sh"
args = []
}
}
task "launch" {
group "${org}" {
task "configure" {
env {
RUNNER_CFG_PAT = "${token}"
}
lifecycle {
hook = "prestart"
}
driver = "exec"
artifact {
source = "https://github.com/actions/runner/releases/download/v${runner_version}/actions-runner-linux-arm64-${runner_version}.tar.gz"
source = "https://github.com/actions/runner/releases/download/v${runner_version}/actions-runner-linux-$${attr.cpu.arch}-${runner_version}.tar.gz"
destination = "$${NOMAD_ALLOC_DIR}/actions-runner"
mode = "dir"
}
config {
command = "config.sh"
command = "$${NOMAD_ALLOC_DIR}/actions-runner/config.sh"
args = [
"config.sh",
"--unattended",
"--url", "https://github.com/${org_name}",
"--url", "https://github.com/${org}",
"--token", "${token}",
"--labels", "test"
"--labels", "hah",
"--ephemeral"
]
}
}

task "launch" {
driver = "exec"
config {
command = "$${NOMAD_ALLOC_DIR}/actions-runner/run.sh"
}
scaling "cpu" {
enabled = true
min = 100
max = 150
policy {
cooldown = "5m"
evaluation_interval = "10s"
strategy "target-value" {
target = 2
}
}
}
}

task "remove" {
lifecycle {
hook = "poststop"
sidecar = false
}
driver = "exec"
config {
command = "config.sh"
command = "$${NOMAD_ALLOC_DIR}/actions-runner/config.sh"
args = [
"remove",
"--token",
"${token}"
]
}
}
}
} // remove task
} // task group
}

0 comments on commit 1a22d56

Please sign in to comment.