Skip to content

Commit

Permalink
refactor: check platform
Browse files Browse the repository at this point in the history
  • Loading branch information
boywithkeyboard committed Mar 24, 2024
1 parent 87e686b commit 03dc984
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
7 changes: 5 additions & 2 deletions build/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18855,6 +18855,7 @@ Support boolean input list: \`true | True | TRUE | false | False | FALSE\``);
// src/index.ts
var import_core = __toESM(require_core());
var import_node_child_process = require("node:child_process");
var import_node_os = require("node:os");

// src/fetchTrace.ts
async function fetchTrace() {
Expand Down Expand Up @@ -18883,14 +18884,16 @@ try {
if (/^off|malware|full$/.test(familyMode) === false) {
throw new Error("Bad option: familyMode");
}
if ((0, import_node_os.platform)() !== "linux") {
throw new Error("This action is only available for Linux!");
}
(0, import_node_child_process.execSync)("curl -fsSL https://pkg.cloudflareclient.com/pubkey.gpg | sudo gpg --yes --dearmor --output /usr/share/keyrings/cloudflare-warp-archive-keyring.gpg");
(0, import_node_child_process.execSync)('echo "deb [signed-by=/usr/share/keyrings/cloudflare-warp-archive-keyring.gpg] https://pkg.cloudflareclient.com/ $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/cloudflare-client.list');
(0, import_node_child_process.execSync)("sudo apt-get -y update && sudo apt-get install -y cloudflare-warp");
(0, import_node_child_process.execSync)("sudo warp-cli --accept-tos registration new");
(0, import_node_child_process.execSync)(`sudo warp-cli --accept-tos mode ${onlyDoH ? "doh" : "warp+doh"}`);
(0, import_node_child_process.execSync)(`sudo warp-cli --accept-tos dns families ${familyMode}`);
const result = (0, import_node_child_process.execSync)("sudo warp-cli --accept-tos connect");
console.log(result.toString("utf-8"));
(0, import_node_child_process.execSync)("sudo warp-cli --accept-tos connect");
await wait(1e3);
const trace = await fetchTrace();
if (trace.warp === "off") {
Expand Down
9 changes: 6 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { getBooleanInput, getInput, setFailed } from '@actions/core'
import { execSync } from 'node:child_process'
import { platform } from 'node:os'
import { fetchTrace } from './fetchTrace'
import { wait } from './wait'

Expand All @@ -12,6 +13,10 @@ try {
throw new Error('Bad option: familyMode')
}

if (platform() !== 'linux') {
throw new Error('This action is only available for Linux!')
}

// add cloudflare gpg key
execSync('curl -fsSL https://pkg.cloudflareclient.com/pubkey.gpg | sudo gpg --yes --dearmor --output /usr/share/keyrings/cloudflare-warp-archive-keyring.gpg')

Expand All @@ -25,9 +30,7 @@ try {
execSync('sudo warp-cli --accept-tos registration new')
execSync(`sudo warp-cli --accept-tos mode ${onlyDoH ? 'doh' : 'warp+doh'}`)
execSync(`sudo warp-cli --accept-tos dns families ${familyMode}`)
const result = execSync('sudo warp-cli --accept-tos connect')

console.log(result.toString('utf-8'))
execSync('sudo warp-cli --accept-tos connect')

// verify installation
await wait(1000)
Expand Down

0 comments on commit 03dc984

Please sign in to comment.