@@ -16106,6 +16106,38 @@ function exportVariable(name, val) {
1610616106 issueCommand("set-env", { name }, convertedVal);
1610716107}
1610816108/**
16109+ * Registers a secret which will get masked from logs
16110+ *
16111+ * @param secret - Value of the secret to be masked
16112+ * @remarks
16113+ * This function instructs the Actions runner to mask the specified value in any
16114+ * logs produced during the workflow run. Once registered, the secret value will
16115+ * be replaced with asterisks (***) whenever it appears in console output, logs,
16116+ * or error messages.
16117+ *
16118+ * This is useful for protecting sensitive information such as:
16119+ * - API keys
16120+ * - Access tokens
16121+ * - Authentication credentials
16122+ * - URL parameters containing signatures (SAS tokens)
16123+ *
16124+ * Note that masking only affects future logs; any previous appearances of the
16125+ * secret in logs before calling this function will remain unmasked.
16126+ *
16127+ * @example
16128+ * ```typescript
16129+ * // Register an API token as a secret
16130+ * const apiToken = "abc123xyz456";
16131+ * setSecret(apiToken);
16132+ *
16133+ * // Now any logs containing this value will show *** instead
16134+ * console.log(`Using token: ${apiToken}`); // Outputs: "Using token: ***"
16135+ * ```
16136+ */
16137+ function setSecret(secret) {
16138+ issueCommand("add-mask", {}, secret);
16139+ }
16140+ /**
1610916141* Gets the value of an input.
1611016142* Unless trimWhitespace is set to false in InputOptions, the value is also trimmed.
1611116143* Returns an empty string if the value is not defined.
@@ -36650,10 +36682,30 @@ async function ssh() {
3665036682 let privateKey = getInput("private-key");
3665136683 if (privateKey !== "") {
3665236684 privateKey = privateKey.replace(/\r/g, "").trim() + "\n";
36653- const p = $`ssh-add -`;
36654- p.stdin.write(privateKey);
36655- p.stdin.end();
36656- await p;
36685+ const passphrase = getInput("private-key-passphrase");
36686+ if (passphrase === "") {
36687+ const p = $`ssh-add -`;
36688+ p.stdin.write(privateKey);
36689+ p.stdin.end();
36690+ await p;
36691+ } else {
36692+ setSecret(passphrase);
36693+ const keyPath = `${process.env["RUNNER_TEMP"] ?? "/tmp"}/deployer-ssh-key`;
36694+ const askpassPath = `${process.env["RUNNER_TEMP"] ?? "/tmp"}/deployer-ssh-askpass.sh`;
36695+ fs.writeFileSync(keyPath, privateKey, { mode: 384 });
36696+ fs.writeFileSync(askpassPath, `#!/bin/sh\nprintf '%s\\n' \"$DEPLOYER_SSH_KEY_PASSPHRASE\"\n`, { mode: 448 });
36697+ try {
36698+ process.env["DEPLOYER_SSH_KEY_PASSPHRASE"] = passphrase;
36699+ process.env["SSH_ASKPASS"] = askpassPath;
36700+ process.env["SSH_ASKPASS_REQUIRE"] = "force";
36701+ process.env["DISPLAY"] = process.env["DISPLAY"] ?? ":0";
36702+ await $`ssh-add ${keyPath}`;
36703+ } finally {
36704+ delete process.env["DEPLOYER_SSH_KEY_PASSPHRASE"];
36705+ fs.rmSync(keyPath, { force: true });
36706+ fs.rmSync(askpassPath, { force: true });
36707+ }
36708+ }
3665736709 }
3665836710 const knownHosts = getInput("known-hosts");
3665936711 if (knownHosts !== "") {
0 commit comments