mirror of
https://github.com/DeterminateSystems/nix-installer-action.git
synced 2024-12-23 13:32:06 +01:00
Disable docker under act (#90)
* Rename IN_GITHUB_ACTIONS to IN_ACT * If the trusted runner user is truthy, setup the runner as a trusted user. The boolean option is always set. * Set HAS_SYSTEMD in more cases * Unquote trust-runner-user in the action.yml * Don't bother with the docker shim under act * fmt * Regenerate * fixup
This commit is contained in:
parent
5c2710f363
commit
75ffa7fc74
3 changed files with 22 additions and 9 deletions
|
@ -113,7 +113,7 @@ inputs:
|
||||||
default: "https://install.determinate.systems/nix-installer/diagnostic"
|
default: "https://install.determinate.systems/nix-installer/diagnostic"
|
||||||
trust-runner-user:
|
trust-runner-user:
|
||||||
description: Whether to make the runner user trusted by the Nix daemon
|
description: Whether to make the runner user trusted by the Nix daemon
|
||||||
default: "true"
|
default: true
|
||||||
nix-installer-branch:
|
nix-installer-branch:
|
||||||
description: (deprecated) The branch of `nix-installer` to use (conflicts with `nix-installer-tag`, `nix-installer-revision`, `nix-installer-pr`)
|
description: (deprecated) The branch of `nix-installer` to use (conflicts with `nix-installer-tag`, `nix-installer-revision`, `nix-installer-pr`)
|
||||||
required: false
|
required: false
|
||||||
|
|
14
dist/index.js
generated
vendored
14
dist/index.js
generated
vendored
|
@ -97332,7 +97332,7 @@ var EVENT_LOGIN_TO_FLAKEHUB = "login_to_flakehub";
|
||||||
var EVENT_CONCLUDE_WORKFLOW = "conclude_workflow";
|
var EVENT_CONCLUDE_WORKFLOW = "conclude_workflow";
|
||||||
var FACT_HAS_DOCKER = "has_docker";
|
var FACT_HAS_DOCKER = "has_docker";
|
||||||
var FACT_HAS_SYSTEMD = "has_systemd";
|
var FACT_HAS_SYSTEMD = "has_systemd";
|
||||||
var FACT_IN_GITHUB_ACTIONS = "in_act";
|
var FACT_IN_ACT = "in_act";
|
||||||
var FACT_IN_NAMESPACE_SO = "in_namespace_so";
|
var FACT_IN_NAMESPACE_SO = "in_namespace_so";
|
||||||
var FACT_NIX_INSTALLER_PLANNER = "nix_installer_planner";
|
var FACT_NIX_INSTALLER_PLANNER = "nix_installer_planner";
|
||||||
var NixInstallerAction = class {
|
var NixInstallerAction = class {
|
||||||
|
@ -97385,16 +97385,22 @@ var NixInstallerAction = class {
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (process.env["ACT"] && !process.env["NOT_ACT"]) {
|
||||||
|
core.debug(
|
||||||
|
"Not bothering to detect if the docker shim should be used, as it is typically incompatible with act."
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
const systemdCheck = external_node_fs_namespaceObject.statSync("/run/systemd/system", {
|
const systemdCheck = external_node_fs_namespaceObject.statSync("/run/systemd/system", {
|
||||||
throwIfNoEntry: false
|
throwIfNoEntry: false
|
||||||
});
|
});
|
||||||
if (systemdCheck?.isDirectory()) {
|
if (systemdCheck?.isDirectory()) {
|
||||||
|
this.idslib.addFact(FACT_HAS_SYSTEMD, true);
|
||||||
if (this.forceDockerShim) {
|
if (this.forceDockerShim) {
|
||||||
core.warning(
|
core.warning(
|
||||||
"Systemd is detected, but ignoring it since force-docker-shim is enabled."
|
"Systemd is detected, but ignoring it since force-docker-shim is enabled."
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
this.idslib.addFact(FACT_HAS_SYSTEMD, true);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -97638,7 +97644,7 @@ ${stderrBuffer}`
|
||||||
extraConf += `access-tokens = ${serverUrl}=${this.githubToken}`;
|
extraConf += `access-tokens = ${serverUrl}=${this.githubToken}`;
|
||||||
extraConf += "\n";
|
extraConf += "\n";
|
||||||
}
|
}
|
||||||
if (this.trustRunnerUser !== null) {
|
if (this.trustRunnerUser) {
|
||||||
const user = (0,external_node_os_.userInfo)().username;
|
const user = (0,external_node_os_.userInfo)().username;
|
||||||
if (user) {
|
if (user) {
|
||||||
extraConf += `trusted-users = root ${user}`;
|
extraConf += `trusted-users = root ${user}`;
|
||||||
|
@ -97662,7 +97668,7 @@ ${stderrBuffer}`
|
||||||
}
|
}
|
||||||
executionEnv.NIX_INSTALLER_EXTRA_CONF = extraConf;
|
executionEnv.NIX_INSTALLER_EXTRA_CONF = extraConf;
|
||||||
if (process.env["ACT"] && !process.env["NOT_ACT"]) {
|
if (process.env["ACT"] && !process.env["NOT_ACT"]) {
|
||||||
this.idslib.addFact(FACT_IN_GITHUB_ACTIONS, true);
|
this.idslib.addFact(FACT_IN_ACT, true);
|
||||||
core.info(
|
core.info(
|
||||||
"Detected `$ACT` environment, assuming this is a https://github.com/nektos/act created container, set `NOT_ACT=true` to override this. This will change the setting of the `init` to be compatible with `act`"
|
"Detected `$ACT` environment, assuming this is a https://github.com/nektos/act created container, set `NOT_ACT=true` to override this. This will change the setting of the `init` to be compatible with `act`"
|
||||||
);
|
);
|
||||||
|
|
15
src/index.ts
15
src/index.ts
|
@ -30,7 +30,7 @@ const EVENT_CONCLUDE_WORKFLOW = "conclude_workflow";
|
||||||
// Facts
|
// Facts
|
||||||
const FACT_HAS_DOCKER = "has_docker";
|
const FACT_HAS_DOCKER = "has_docker";
|
||||||
const FACT_HAS_SYSTEMD = "has_systemd";
|
const FACT_HAS_SYSTEMD = "has_systemd";
|
||||||
const FACT_IN_GITHUB_ACTIONS = "in_act";
|
const FACT_IN_ACT = "in_act";
|
||||||
const FACT_IN_NAMESPACE_SO = "in_namespace_so";
|
const FACT_IN_NAMESPACE_SO = "in_namespace_so";
|
||||||
const FACT_NIX_INSTALLER_PLANNER = "nix_installer_planner";
|
const FACT_NIX_INSTALLER_PLANNER = "nix_installer_planner";
|
||||||
|
|
||||||
|
@ -123,16 +123,23 @@ class NixInstallerAction {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (process.env["ACT"] && !process.env["NOT_ACT"]) {
|
||||||
|
actionsCore.debug(
|
||||||
|
"Not bothering to detect if the docker shim should be used, as it is typically incompatible with act.",
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const systemdCheck = fs.statSync("/run/systemd/system", {
|
const systemdCheck = fs.statSync("/run/systemd/system", {
|
||||||
throwIfNoEntry: false,
|
throwIfNoEntry: false,
|
||||||
});
|
});
|
||||||
if (systemdCheck?.isDirectory()) {
|
if (systemdCheck?.isDirectory()) {
|
||||||
|
this.idslib.addFact(FACT_HAS_SYSTEMD, true);
|
||||||
if (this.forceDockerShim) {
|
if (this.forceDockerShim) {
|
||||||
actionsCore.warning(
|
actionsCore.warning(
|
||||||
"Systemd is detected, but ignoring it since force-docker-shim is enabled.",
|
"Systemd is detected, but ignoring it since force-docker-shim is enabled.",
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
this.idslib.addFact(FACT_HAS_SYSTEMD, true);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -428,7 +435,7 @@ class NixInstallerAction {
|
||||||
extraConf += `access-tokens = ${serverUrl}=${this.githubToken}`;
|
extraConf += `access-tokens = ${serverUrl}=${this.githubToken}`;
|
||||||
extraConf += "\n";
|
extraConf += "\n";
|
||||||
}
|
}
|
||||||
if (this.trustRunnerUser !== null) {
|
if (this.trustRunnerUser) {
|
||||||
const user = userInfo().username;
|
const user = userInfo().username;
|
||||||
if (user) {
|
if (user) {
|
||||||
extraConf += `trusted-users = root ${user}`;
|
extraConf += `trusted-users = root ${user}`;
|
||||||
|
@ -453,7 +460,7 @@ class NixInstallerAction {
|
||||||
executionEnv.NIX_INSTALLER_EXTRA_CONF = extraConf;
|
executionEnv.NIX_INSTALLER_EXTRA_CONF = extraConf;
|
||||||
|
|
||||||
if (process.env["ACT"] && !process.env["NOT_ACT"]) {
|
if (process.env["ACT"] && !process.env["NOT_ACT"]) {
|
||||||
this.idslib.addFact(FACT_IN_GITHUB_ACTIONS, true);
|
this.idslib.addFact(FACT_IN_ACT, true);
|
||||||
actionsCore.info(
|
actionsCore.info(
|
||||||
"Detected `$ACT` environment, assuming this is a https://github.com/nektos/act created container, set `NOT_ACT=true` to override this. This will change the setting of the `init` to be compatible with `act`",
|
"Detected `$ACT` environment, assuming this is a https://github.com/nektos/act created container, set `NOT_ACT=true` to override this. This will change the setting of the `init` to be compatible with `act`",
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue