-
Notifications
You must be signed in to change notification settings - Fork 0
add retry logic to the action #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,8 @@ function getConfig() { | |
| .filter(Boolean), | ||
| skipDrafts: core.getInput("skip-drafts") !== "false", | ||
| requiredApprovals: parseInt(core.getInput("required-approvals"), 10) || 0, | ||
| mergeRetries: parseInt(core.getInput("merge-retries"), 10), | ||
| mergeRetrySleep: parseInt(core.getInput("merge-retry-sleep"), 10), | ||
| }; | ||
| } | ||
|
|
||
|
|
@@ -194,17 +196,34 @@ async function processPR(octokit, owner, repo, prNumber, config) { | |
|
|
||
| core.info("Adding to merge queue…"); | ||
|
|
||
| try { | ||
| const entry = await enqueue(octokit, pr.id); | ||
| if (entry) { | ||
| core.info( | ||
| `Added to merge queue: position=${entry.position}, state=${entry.state}` | ||
| ); | ||
| } else { | ||
| core.info("Added to merge queue (no entry details returned)"); | ||
| // Retry logic for enqueue | ||
| const maxRetries = typeof config.mergeRetries === 'number' && !isNaN(config.mergeRetries) ? config.mergeRetries : 6; | ||
| const retrySleep = typeof config.mergeRetrySleep === 'number' && !isNaN(config.mergeRetrySleep) ? config.mergeRetrySleep : 5000; | ||
|
|
||
| let attempt = 0; | ||
| while (attempt <= maxRetries) { | ||
|
Comment on lines
+203
to
+204
|
||
| try { | ||
| const entry = await enqueue(octokit, pr.id); | ||
| if (entry) { | ||
| core.info( | ||
| `Added to merge queue: position=${entry.position}, state=${entry.state}` | ||
| ); | ||
| } else { | ||
| core.info("Added to merge queue (no entry details returned)"); | ||
| } | ||
| return; | ||
| } catch (err) { | ||
|
Comment on lines
+199
to
+215
|
||
| if (maxRetries === 0 || attempt === maxRetries) { | ||
| core.setFailed(`Failed to enqueue PR #${prNumber}: ${err.message}`); | ||
| return; | ||
| } | ||
| core.warning(`Enqueue failed (attempt ${attempt + 1}/${maxRetries + 1}): ${err.message}`); | ||
| if (retrySleep > 0) { | ||
| core.info(`Sleeping for ${retrySleep}ms before retrying…`); | ||
| await new Promise((resolve) => setTimeout(resolve, retrySleep)); | ||
| } | ||
| } | ||
| } catch (err) { | ||
| core.setFailed(`Failed to enqueue PR #${prNumber}: ${err.message}`); | ||
| attempt++; | ||
| } | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
action.ymlis invalid YAML / invalid action metadata: the file starts with an unexpectedr merge-retries:key and the new inputs are defined beforename:and outside theinputs:map. GitHub Actions will ignore/break these inputs. Movemerge-retriesandmerge-retry-sleepunder the existinginputs:section and remove the stray leadingr/fix indentation so the file has a valid top-level schema (name,description,inputs,runs, etc.).