@higherdev/cli 0.35.0 → 0.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions-runner.js +15 -3
- package/package.json +1 -1
package/dist/actions-runner.js
CHANGED
|
@@ -22,6 +22,15 @@ function unitPath(value) {
|
|
|
22
22
|
function unitEnvironment(name, value) {
|
|
23
23
|
return `"${name}=${value.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/%/g, "%%")}"`;
|
|
24
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* A systemd user service inherits the supplementary groups the user manager had
|
|
27
|
+
* when it started, so a docker group granted later never reaches the runner.
|
|
28
|
+
* Starting through `sg <group>` picks the group up per membership in /etc/group.
|
|
29
|
+
*/
|
|
30
|
+
export function actionsRunnerExecStart(runnerDir, viaGroup) {
|
|
31
|
+
const service = path.join(runnerDir, "bin/runsvc.sh");
|
|
32
|
+
return viaGroup ? `/usr/bin/sg ${viaGroup} -c "${unitPath(service)}"` : unitPath(service);
|
|
33
|
+
}
|
|
25
34
|
export function actionsRunnerSystemdUnit(input) {
|
|
26
35
|
return `[Unit]
|
|
27
36
|
Description=HDX GitHub Actions runner${input.repo ? ` for ${input.repo}` : ""}
|
|
@@ -32,7 +41,7 @@ Wants=network-online.target
|
|
|
32
41
|
Type=simple
|
|
33
42
|
WorkingDirectory=${unitPath(input.runnerDir)}
|
|
34
43
|
Environment=${unitEnvironment("PATH", input.path)}
|
|
35
|
-
ExecStart=${
|
|
44
|
+
ExecStart=${actionsRunnerExecStart(input.runnerDir, input.viaGroup)}
|
|
36
45
|
Restart=always
|
|
37
46
|
RestartSec=5
|
|
38
47
|
KillMode=process
|
|
@@ -105,10 +114,13 @@ export async function installActionsRunner(options, deps = {}) {
|
|
|
105
114
|
throw new Error(`Existing Actions runner in ${runnerDir} belongs to another host or repository.`);
|
|
106
115
|
}
|
|
107
116
|
}
|
|
117
|
+
// Jobs with service containers need the Docker socket; run through the docker group when the user has it.
|
|
118
|
+
const groups = (await run("id", ["-nG"]).catch(() => ({ stdout: "" }))).stdout.trim().split(/\s+/);
|
|
119
|
+
const viaGroup = groups.includes("docker") && await exists("/usr/bin/sg") ? "docker" : null;
|
|
108
120
|
await mkdir(path.dirname(unitPath), { recursive: true });
|
|
109
|
-
await writeFile(unitPath, actionsRunnerSystemdUnit({ runnerDir, path: pathValue, repo: options.repo }), "utf8");
|
|
121
|
+
await writeFile(unitPath, actionsRunnerSystemdUnit({ runnerDir, path: pathValue, repo: options.repo, viaGroup }), "utf8");
|
|
110
122
|
await run("systemctl", ["--user", "daemon-reload"]);
|
|
111
123
|
await run("systemctl", ["--user", "enable", "--now", unitName]);
|
|
112
124
|
return [`GitHub Actions runner ${options.host} registered to ${options.repo}.`,
|
|
113
|
-
`labels: self-hosted, hdx, ${options.host}`, `systemd unit: ${unitPath}`];
|
|
125
|
+
`labels: self-hosted, hdx, ${options.host}`, `systemd unit: ${unitPath}${viaGroup ? ` (via sg ${viaGroup})` : ""}`];
|
|
114
126
|
}
|