Skip to content

Commit

Permalink
Merge pull request #26 from Devils-Knight/logging
Browse files Browse the repository at this point in the history
Update Build log for wait-for-secrets action
  • Loading branch information
varunsh-coder authored Sep 20, 2022
2 parents cca2533 + b583b08 commit 05d41a4
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 31 deletions.
25 changes: 12 additions & 13 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.

33 changes: 16 additions & 17 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@ import * as core from "@actions/core";
await sendToSlack(slackWebhookUrl, secretUrl);
}

while (true) {
var authIDToken = await core.getIDToken();
var secretsString = "";
var authIDToken = await core.getIDToken();
var secretsString = "";

core.getMultilineInput("secrets").forEach((secret) => {
secretsString = secretsString + secret + ",";
});
core.getMultilineInput("secrets").forEach((secret) => {
secretsString = secretsString + secret + ",";
});

secretsString = secretsString.slice(0, -1);
secretsString = secretsString.slice(0, -1);

var url =
"https://prod.api.stepsecurity.io/v1/secrets?secrets=" + secretsString;
var url =
"https://prod.api.stepsecurity.io/v1/secrets?secrets=" + secretsString;

while (true) {
try {
const additionalHeaders = { Authorization: "Bearer " + authIDToken };

Expand All @@ -52,30 +52,29 @@ import * as core from "@actions/core";
core.setSecret(secret.Value);
});

console.log("Successfully set secrets!");
console.log("\nSuccessfully set secrets!");
var response = await _http.del(url, additionalHeaders);
if (response.message.statusCode === 200) {
console.log("Successfully cleared secrets");
}
break;
} else {
await sleep(9000);

console.log("Visit the URL to input the secrets:");
console.log("\x1b[32m%s\x1b[0m","Visit this URL to input secrets:");
console.log(secretUrl);

await sleep(9000);
}
console.log(`retrying...`);

counter++;
if (counter > 60) {
console.log("timed out");
console.log("\ntimed out");
break;
}
await sleep(1000);
} else {
let body: string = await response.readBody();
console.log(`response: ${body}`);
if (body !== "Token used before issued") {
console.log(`\nresponse: ${body}`);
break;
}
}
Expand Down Expand Up @@ -103,4 +102,4 @@ function sleep(ms) {
return new Promise((resolve) => {
setTimeout(resolve, ms);
});
}
}

0 comments on commit 05d41a4

Please sign in to comment.