Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
varunsh-coder committed Aug 20, 2024
1 parent 247a5c6 commit 4330132
Show file tree
Hide file tree
Showing 9 changed files with 106 additions and 131 deletions.
4 changes: 2 additions & 2 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/post/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/post/index.js.map

Large diffs are not rendered by default.

158 changes: 65 additions & 93 deletions dist/pre/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/pre/index.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ export const HARDEN_RUNNER_UNAVAILABLE_MESSAGE =
"Sorry, we are currently experiencing issues with the Harden Runner installation process. It is currently unavailable.";

export const ARC_RUNNER_MESSAGE =
"Workflow is currently being executed in ARC based runner";
"Workflow is currently being executed in ARC based runner.";

export const ARM64_RUNNER_MESSAGE =
"Sorry, arm64 runners for public repos are not supported yet.";
"ARM runners are not supported in the Harden-Runner community tier.";
19 changes: 10 additions & 9 deletions src/install-agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ import { verifyChecksum } from "./checksum";
import { EOL } from "os";
import { ARM64_RUNNER_MESSAGE } from "./common";

export async function installAgent(isTLS: boolean, configStr: string) {
export async function installAgent(
isTLS: boolean,
configStr: string
): Promise<boolean> {
// Note: to avoid github rate limiting
let token = core.getInput("token");
let auth = `token ${token}`;
const token = core.getInput("token", { required: true });
const auth = `token ${token}`;

let downloadPath: string;
const variant = process.arch === "x64" ? "amd64" : "arm64";

let variant = "arm64";
if (process.arch === "x64") {
variant = "amd64";
}
let downloadPath: string;

fs.appendFileSync(process.env.GITHUB_STATE, `isTLS=${isTLS}${EOL}`, {
encoding: "utf8",
Expand All @@ -30,7 +30,7 @@ export async function installAgent(isTLS: boolean, configStr: string) {
} else {
if (variant === "arm64") {
console.log(ARM64_RUNNER_MESSAGE);
process.exit(0);
return false;
}
downloadPath = await tc.downloadTool(
"https://github.com/step-security/agent/releases/download/v0.13.7/agent_0.13.7_linux_amd64.tar.gz",
Expand Down Expand Up @@ -61,4 +61,5 @@ export async function installAgent(isTLS: boolean, configStr: string) {
cp.execFileSync(cmd, args);
cp.execSync("sudo systemctl daemon-reload");
cp.execSync("sudo service agent start", { timeout: 15000 });
return true;
}
42 changes: 22 additions & 20 deletions src/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,30 +229,32 @@ interface MonitorResponse {

let isTLS = await isTLSEnabled(context.repo.owner);

await installAgent(isTLS, confgStr);
const agentInstalled = await installAgent(isTLS, confgStr);

// Check that the file exists locally
var statusFile = "/home/agent/agent.status";
var logFile = "/home/agent/agent.log";
var counter = 0;
while (true) {
if (!fs.existsSync(statusFile)) {
counter++;
if (counter > 30) {
console.log("timed out");
if (fs.existsSync(logFile)) {
var content = fs.readFileSync(logFile, "utf-8");
console.log(content);
if (agentInstalled) {
// Check that the file exists locally
var statusFile = "/home/agent/agent.status";
var logFile = "/home/agent/agent.log";
var counter = 0;
while (true) {
if (!fs.existsSync(statusFile)) {
counter++;
if (counter > 30) {
console.log("timed out");
if (fs.existsSync(logFile)) {
var content = fs.readFileSync(logFile, "utf-8");
console.log(content);
}
break;
}
await sleep(300);
} // The file *does* exist
else {
// Read the file
var content = fs.readFileSync(statusFile, "utf-8");
console.log(content);
break;
}
await sleep(300);
} // The file *does* exist
else {
// Read the file
var content = fs.readFileSync(statusFile, "utf-8");
console.log(content);
break;
}
}
} catch (error) {
Expand Down

0 comments on commit 4330132

Please sign in to comment.