Skip to content

Commit 3f9bf2f

Browse files
committed
feat: add RETRY_ATTEMPT environment variable
1 parent 9417ab4 commit 3f9bf2f

File tree

2 files changed

+29
-6
lines changed

2 files changed

+29
-6
lines changed

dist/index.js

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24852,6 +24852,17 @@ exports["default"] = _default;
2485224852

2485324853
"use strict";
2485424854

24855+
var __assign = (this && this.__assign) || function () {
24856+
__assign = Object.assign || function(t) {
24857+
for (var s, i = 1, n = arguments.length; i < n; i++) {
24858+
s = arguments[i];
24859+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
24860+
t[p] = s[p];
24861+
}
24862+
return t;
24863+
};
24864+
return __assign.apply(this, arguments);
24865+
};
2485524866
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2485624867
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
2485724868
return new (P || (P = Promise))(function (resolve, reject) {
@@ -24978,8 +24989,14 @@ function runCmd(attempt, inputs) {
2497824989
timeout = false;
2497924990
(0, core_1.debug)("Running command ".concat(inputs.command, " on ").concat(OS, " using shell ").concat(executable));
2498024991
child = attempt > 1 && inputs.new_command_on_retry
24981-
? (0, child_process_1.spawn)(inputs.new_command_on_retry, { shell: executable })
24982-
: (0, child_process_1.spawn)(inputs.command, { shell: executable });
24992+
? (0, child_process_1.spawn)(inputs.new_command_on_retry, {
24993+
shell: executable,
24994+
env: __assign(__assign({}, process.env), { RETRY_ATTEMPT: "".concat(attempt) }),
24995+
})
24996+
: (0, child_process_1.spawn)(inputs.command, {
24997+
shell: executable,
24998+
env: __assign(__assign({}, process.env), { RETRY_ATTEMPT: "".concat(attempt) }),
24999+
});
2498325000
(_a = child.stdout) === null || _a === void 0 ? void 0 : _a.on('data', function (data) {
2498425001
process.stdout.write(data);
2498525002
});
@@ -25041,7 +25058,7 @@ function runAction(inputs) {
2504125058
_a.label = 2;
2504225059
case 2:
2504325060
if (!(attempt <= inputs.max_attempts)) return [3 /*break*/, 14];
25044-
(0, core_1.info)("::group::Attempt ".concat(attempt));
25061+
(0, core_1.info)("::group::Attempt ".concat(attempt, " is this working?"));
2504525062
_a.label = 3;
2504625063
case 3:
2504725064
_a.trys.push([3, 5, 12, 13]);

src/index.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,14 @@ async function runCmd(attempt: number, inputs: Inputs) {
7878
debug(`Running command ${inputs.command} on ${OS} using shell ${executable}`);
7979
const child =
8080
attempt > 1 && inputs.new_command_on_retry
81-
? spawn(inputs.new_command_on_retry, { shell: executable })
82-
: spawn(inputs.command, { shell: executable });
81+
? spawn(inputs.new_command_on_retry, {
82+
shell: executable,
83+
env: { ...process.env, RETRY_ATTEMPT: `${attempt}` },
84+
})
85+
: spawn(inputs.command, {
86+
shell: executable,
87+
env: { ...process.env, RETRY_ATTEMPT: `${attempt}` },
88+
});
8389

8490
child.stdout?.on('data', (data) => {
8591
process.stdout.write(data);
@@ -130,7 +136,7 @@ async function runAction(inputs: Inputs) {
130136
await validateInputs(inputs);
131137

132138
for (let attempt = 1; attempt <= inputs.max_attempts; attempt++) {
133-
info(`::group::Attempt ${attempt}`);
139+
info(`::group::Attempt ${attempt} is this working?`);
134140
try {
135141
// just keep overwriting attempts output
136142
setOutput(OUTPUT_TOTAL_ATTEMPTS_KEY, attempt);

0 commit comments

Comments
 (0)