@@ -25686,10 +25686,13 @@ var __importStar = (this && this.__importStar) || (function () {
2568625686Object.defineProperty(exports, "__esModule", ({ value: true }));
2568725687const core = __importStar(__nccwpck_require__(7484));
2568825688const exec = __importStar(__nccwpck_require__(5236));
25689+ const fs = __importStar(__nccwpck_require__(9896));
25690+ const runnerWindows = "Windows";
25691+ const runnerMacOS = "macOS";
2568925692async function logout() {
2569025693 try {
2569125694 const runnerOS = process.env.RUNNER_OS || "";
25692- if (runnerOS === "macOS" ) {
25695+ if (runnerOS === runnerMacOS ) {
2569325696 // The below is required to allow GitHub's post job cleanup to complete.
2569425697 core.info("Resetting DNS settings on macOS");
2569525698 await exec.exec("networksetup", ["-setdnsservers", "Ethernet", "Empty"]);
@@ -25703,29 +25706,50 @@ async function logout() {
2570325706 // Check if tailscale is available first
2570425707 try {
2570525708 await exec.exec("tailscale", ["--version"], { silent: true });
25709+ // Determine the correct command based on OS
25710+ let execArgs;
25711+ if (runnerOS === runnerWindows) {
25712+ execArgs = ["tailscale", "logout"];
25713+ }
25714+ else {
25715+ // Linux and macOS - use system-installed binary with sudo
25716+ execArgs = ["sudo", "-E", "tailscale", "logout"];
25717+ }
25718+ core.info(`Running: ${execArgs.join(" ")}`);
25719+ try {
25720+ await exec.exec(execArgs[0], execArgs.slice(1));
25721+ core.info("✅ Successfully logged out of Tailscale");
25722+ }
25723+ catch (error) {
25724+ // Don't fail the action if logout fails - it's just cleanup
25725+ core.warning(`Failed to logout from Tailscale: ${error}`);
25726+ core.info("Your ephemeral node will eventually be cleaned up by Tailscale");
25727+ }
2570625728 }
2570725729 catch (error) {
2570825730 core.info("Tailscale not found or not accessible, skipping logout");
2570925731 return;
2571025732 }
25711- // Determine the correct command based on OS
25712- let execArgs;
25713- if (runnerOS === "Windows") {
25714- execArgs = ["tailscale", "logout"];
25715- }
25716- else {
25717- // Linux and macOS - use system-installed binary with sudo
25718- execArgs = ["sudo", "-E", "tailscale", "logout"];
25719- }
25720- core.info(`Running: ${execArgs.join(" ")}`);
25733+ core.info("Stopping tailscale");
2572125734 try {
25722- await exec.exec(execArgs[0], execArgs.slice(1));
25723- core.info("✅ Successfully logged out of Tailscale");
25735+ if (runnerOS === runnerWindows) {
25736+ await exec.exec("net", ["stop", "Tailscale"]);
25737+ await exec.exec("taskkill", ["/F", "/IM", "tailscale-ipn.exe"]);
25738+ }
25739+ else {
25740+ const pid = fs.readFileSync("tailscaled.pid").toString();
25741+ if (pid === "") {
25742+ throw new Error("pid file empty");
25743+ }
25744+ // The pid is actually the pid of the `sudo` parent of tailscaled, so use pkill -P to kill children of that parent
25745+ await exec.exec("sudo", ["pkill", "-P", pid]);
25746+ // Clean up DNS and routes.
25747+ await exec.exec("sudo", ["tailscaled", "--cleanup"]);
25748+ }
25749+ core.info("✅ Stopped tailscale");
2572425750 }
2572525751 catch (error) {
25726- // Don't fail the action if logout fails - it's just cleanup
25727- core.warning(`Failed to logout from Tailscale: ${error}`);
25728- core.info("Your ephemeral node will eventually be cleaned up by Tailscale");
25752+ core.warning(`Failed to stop tailscale: ${error}`);
2572925753 }
2573025754 }
2573125755 catch (error) {
0 commit comments