Skip to content

Commit

Permalink
chore: Update dist
Browse files Browse the repository at this point in the history
  • Loading branch information
GitHub Actions committed Jan 18, 2022
1 parent 6b3c017 commit 4e8c221
Showing 1 changed file with 44 additions and 13 deletions.
57 changes: 44 additions & 13 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ module.exports = AWS.MediaLive;
/***/ }),

/***/ 104:
/***/ (function(module, __unusedexports, __webpack_require__) {
/***/ (function(__unusedmodule, exports, __webpack_require__) {

const core = __webpack_require__(6470);
const aws = __webpack_require__(9350);
Expand Down Expand Up @@ -408,6 +408,29 @@ function getStsClient(region) {
});
}

let defaultSleep = function (ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
};
let sleep = defaultSleep;

// retryAndBackoff retries with exponential backoff the promise if the error isRetryable upto maxRetries time.
const retryAndBackoff = async (fn, isRetryable, retries = 0, maxRetries = 12, base = 50) => {
try {
return await fn();
} catch (err) {
if (!isRetryable) {
throw err;
}
// It's retryable, so sleep and retry.
await sleep(Math.random() * (Math.pow(2, retries) * base) );
retries += 1;
if (retries === maxRetries) {
throw err;
}
return await retryAndBackoff(fn, isRetryable, retries, maxRetries, base);
}
}

async function run() {
try {
// Get inputs
Expand Down Expand Up @@ -475,17 +498,18 @@ async function run() {

// Get role credentials if configured to do so
if (roleToAssume) {
const roleCredentials = await assumeRole({
sourceAccountId,
region,
roleToAssume,
roleExternalId,
roleDurationSeconds,
roleSessionName,
roleSkipSessionTagging,
webIdentityTokenFile,
webIdentityToken
});
const roleCredentials = await retryAndBackoff(
async () => { return await assumeRole({
sourceAccountId,
region,
roleToAssume,
roleExternalId,
roleDurationSeconds,
roleSessionName,
roleSkipSessionTagging,
webIdentityTokenFile,
webIdentityToken
}) }, true);
exportCredentials(roleCredentials);
// We need to validate the credentials in 2 of our use-cases
// First: self-hosted runners. If the GITHUB_ACTIONS environment variable
Expand All @@ -509,7 +533,14 @@ async function run() {
}
}

module.exports = run;
exports.withSleep = function (s) {
sleep = s;
};
exports.reset = function () {
sleep = defaultSleep;
};

exports.run = run

/* istanbul ignore next */
if (require.main === require.cache[eval('__filename')]) {
Expand Down

0 comments on commit 4e8c221

Please sign in to comment.