-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(github-runner): redesign the nomad job template to use different …
…orgs Provide different job names and group names Signed-off-by: Bruce Becker <[email protected]>
- Loading branch information
1 parent
da735ce
commit 1a22d56
Showing
2 changed files
with
40 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,7 @@ repos: | |
args: | ||
- fmt | ||
files: nomad | ||
exclude: ".*tpl" | ||
|
||
ci: | ||
autoupdate_branch: main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |