Skip to content

Commit 2976a88

Browse files
committed
miscellaneous cleanup items from upgrading to TypeScript action
Updates tailscale/corp#32821 Signed-off-by: Percy Wegmann <[email protected]>
1 parent 2c45c8a commit 2976a88

File tree

3 files changed

+21
-144
lines changed

3 files changed

+21
-144
lines changed

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,19 @@ with any of the Users on the tailnet, it has to Tag its nodes.
2626

2727
Nodes created by this Action are [marked as Ephemeral](https://tailscale.com/s/ephemeral-nodes) to
2828
and log out immediately after finishing their CI run, at which point they are automatically removed
29-
by the coordination. The nodes are also [marked Preapproved](https://tailscale.com/kb/1085/auth-keys/)
29+
by the coordination server. The nodes are also [marked Preapproved](https://tailscale.com/kb/1085/auth-keys/)
3030
on tailnets which use [Device Approval](https://tailscale.com/kb/1099/device-approval/)
3131

32+
## Prerequisites
33+
34+
Before using the Tailscale GitHub Action, ensure you have the following:
35+
36+
1. A Tailscale account with <Role>Owner, Admin, or Network admin</Role> permissions.
37+
1. A GitHub repository that you have admin access to (required to set up the GitHub Action).
38+
1. At least one configured [tag][kb-tags].
39+
1. An [OAuth client][kb-oauth-clients] ID and secret OR an [auth key][kb-auth-keys].
40+
1. A runner image version >= 2.237.1 (required to support running Node.js 24).
41+
3242
## Eventual consistency
3343

3444
Propagating information about new peers - such as the node created by this action - across your tailnet

dist/index.js

Lines changed: 5 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -41122,7 +41122,6 @@ const tc = __importStar(__nccwpck_require__(33472));
4112241122
const child_process_1 = __nccwpck_require__(35317);
4112341123
const crypto = __importStar(__nccwpck_require__(76982));
4112441124
const fs = __importStar(__nccwpck_require__(79896));
41125-
const http = __importStar(__nccwpck_require__(58611));
4112641125
const os = __importStar(__nccwpck_require__(70857));
4112741126
const path = __importStar(__nccwpck_require__(16928));
4112841127
const promises_1 = __nccwpck_require__(16460);
@@ -41139,75 +41138,11 @@ const versionLatest = "latest";
4113941138
const versionUnstable = "unstable";
4114041139
// Cross-platform Tailscale local API status check
4114141140
async function getTailscaleStatus() {
41142-
const platform = os.platform();
41143-
if (platform === platformWin32) {
41144-
// Windows: use tailscale status command
41145-
const { stdout } = await exec.getExecOutput(cmdTailscale, [
41146-
"status",
41147-
"--json",
41148-
]);
41149-
return JSON.parse(stdout);
41150-
}
41151-
else if (platform === platformDarwin) {
41152-
// macOS: use /var/run/tailscaled.socket
41153-
return new Promise((resolve, reject) => {
41154-
const options = {
41155-
socketPath: "/var/run/tailscaled.socket",
41156-
path: "/localapi/v0/status",
41157-
method: "GET",
41158-
headers: { Host: "local-tailscaled.sock" },
41159-
};
41160-
const req = http.request(options, (res) => {
41161-
let data = "";
41162-
res.on("data", (chunk) => (data += chunk));
41163-
res.on("end", () => {
41164-
try {
41165-
resolve(JSON.parse(data));
41166-
}
41167-
catch (e) {
41168-
reject(e);
41169-
}
41170-
});
41171-
});
41172-
// Set timeout to prevent hanging
41173-
req.setTimeout(5000, () => {
41174-
req.destroy();
41175-
reject(new Error("Request timeout"));
41176-
});
41177-
req.on("error", reject);
41178-
req.end();
41179-
});
41180-
}
41181-
else {
41182-
// Linux: use Unix socket
41183-
return new Promise((resolve, reject) => {
41184-
const options = {
41185-
socketPath: "/run/tailscale/tailscaled.sock",
41186-
path: "/localapi/v0/status",
41187-
method: "GET",
41188-
headers: { Host: "local-tailscaled.sock" },
41189-
};
41190-
const req = http.request(options, (res) => {
41191-
let data = "";
41192-
res.on("data", (chunk) => (data += chunk));
41193-
res.on("end", () => {
41194-
try {
41195-
resolve(JSON.parse(data));
41196-
}
41197-
catch (e) {
41198-
reject(e);
41199-
}
41200-
});
41201-
});
41202-
// Set timeout to prevent hanging
41203-
req.setTimeout(5000, () => {
41204-
req.destroy();
41205-
reject(new Error("Request timeout"));
41206-
});
41207-
req.on("error", reject);
41208-
req.end();
41209-
});
41210-
}
41141+
const { stdout } = await exec.getExecOutput(cmdTailscale, [
41142+
"status",
41143+
"--json",
41144+
]);
41145+
return JSON.parse(stdout);
4121141146
}
4121241147
async function run() {
4121341148
try {

src/main.ts

Lines changed: 5 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import * as tc from "@actions/tool-cache";
88
import { spawn } from "child_process";
99
import * as crypto from "crypto";
1010
import * as fs from "fs";
11-
import * as http from "http";
1211
import * as os from "os";
1312
import * as path from "path";
1413
import { setTimeout as wait } from "timers/promises";
@@ -59,78 +58,11 @@ type tailscaleStatus = {
5958

6059
// Cross-platform Tailscale local API status check
6160
async function getTailscaleStatus(): Promise<tailscaleStatus> {
62-
const platform = os.platform();
63-
64-
if (platform === platformWin32) {
65-
// Windows: use tailscale status command
66-
const { stdout } = await exec.getExecOutput(cmdTailscale, [
67-
"status",
68-
"--json",
69-
]);
70-
return JSON.parse(stdout);
71-
} else if (platform === platformDarwin) {
72-
// macOS: use /var/run/tailscaled.socket
73-
return new Promise((resolve, reject) => {
74-
const options: http.RequestOptions = {
75-
socketPath: "/var/run/tailscaled.socket",
76-
path: "/localapi/v0/status",
77-
method: "GET",
78-
headers: { Host: "local-tailscaled.sock" },
79-
};
80-
81-
const req = http.request(options, (res) => {
82-
let data = "";
83-
res.on("data", (chunk) => (data += chunk));
84-
res.on("end", () => {
85-
try {
86-
resolve(JSON.parse(data));
87-
} catch (e) {
88-
reject(e);
89-
}
90-
});
91-
});
92-
93-
// Set timeout to prevent hanging
94-
req.setTimeout(5000, () => {
95-
req.destroy();
96-
reject(new Error("Request timeout"));
97-
});
98-
99-
req.on("error", reject);
100-
req.end();
101-
});
102-
} else {
103-
// Linux: use Unix socket
104-
return new Promise((resolve, reject) => {
105-
const options: http.RequestOptions = {
106-
socketPath: "/run/tailscale/tailscaled.sock",
107-
path: "/localapi/v0/status",
108-
method: "GET",
109-
headers: { Host: "local-tailscaled.sock" },
110-
};
111-
112-
const req = http.request(options, (res) => {
113-
let data = "";
114-
res.on("data", (chunk) => (data += chunk));
115-
res.on("end", () => {
116-
try {
117-
resolve(JSON.parse(data));
118-
} catch (e) {
119-
reject(e);
120-
}
121-
});
122-
});
123-
124-
// Set timeout to prevent hanging
125-
req.setTimeout(5000, () => {
126-
req.destroy();
127-
reject(new Error("Request timeout"));
128-
});
129-
130-
req.on("error", reject);
131-
req.end();
132-
});
133-
}
61+
const { stdout } = await exec.getExecOutput(cmdTailscale, [
62+
"status",
63+
"--json",
64+
]);
65+
return JSON.parse(stdout);
13466
}
13567

13668
async function run(): Promise<void> {

0 commit comments

Comments
 (0)