add retry logic to the action#3
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds configurable retry behavior when enqueueing eligible pull requests into GitHub’s merge queue, exposing new action inputs and documenting how to use them.
Changes:
- Add
merge-retries/merge-retry-sleepconfiguration handling and enqueue retry loop inprocessPR(). - Define new action inputs for retry count and delay.
- Document the new retry options in the README.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
src/api.js |
Parses new retry inputs and implements retry/sleep behavior around the enqueue call. |
action.yml |
Adds new action inputs intended to configure retries and sleep duration. |
README.md |
Documents the new retry options and provides an example workflow snippet. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // 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; | ||
| let lastError = null; | ||
| while (attempt <= maxRetries) { | ||
| 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) { |
There was a problem hiding this comment.
The action executes dist/index.js (action.yml → runs.main), but dist/index.js still contains the old non-retrying enqueue logic (no merge-retries/merge-retry-sleep handling). Run the build (npm run build) and commit the updated dist/ output so the published action actually includes the retry feature.
| r merge-retries: | ||
| description: > | ||
| Number of times to retry enqueueing if it fails. Default is 6. Set to 0 to disable retry logic. | ||
| required: false | ||
| default: "6" | ||
|
|
||
| merge-retry-sleep: | ||
| description: > | ||
| Time (in milliseconds) to sleep between retries. Default is 5000 (5 seconds). Set to 0 to disable sleeping between retries. | ||
| required: false | ||
| default: "5000" |
There was a problem hiding this comment.
action.yml is invalid YAML / invalid action metadata: the file starts with an unexpected r merge-retries: key and the new inputs are defined before name: and outside the inputs: map. GitHub Actions will ignore/break these inputs. Move merge-retries and merge-retry-sleep under the existing inputs: section and remove the stray leading r/fix indentation so the file has a valid top-level schema (name, description, inputs, runs, etc.).
| 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; | ||
| let lastError = null; | ||
| while (attempt <= maxRetries) { | ||
| try { |
There was a problem hiding this comment.
The retry loop can silently skip enqueueing when merge-retries is set to a negative number: with maxRetries < 0, while (attempt <= maxRetries) never runs and processPR returns without enqueueing or failing. Clamp mergeRetries to a minimum of 0 (and ideally validate it’s an integer) so there is always at least one enqueue attempt.
| let attempt = 0; | ||
| let lastError = null; | ||
| while (attempt <= maxRetries) { |
There was a problem hiding this comment.
lastError is assigned but never read. This makes the retry logic harder to follow; remove it or use it to report a final error after the loop (if you change the control flow).
cc43f79 to
5abafb1
Compare
a561216 to
a55dd32
Compare
add retry logic to the action
add retry logic to the action
add retry logic to the action
This pull request introduces configurable retry logic for enqueueing pull requests into the merge queue, allowing users to control both the number of retries and the delay between them. The changes include updates to the documentation, action inputs, configuration handling, and the main processing logic to support these new options.
New Merge Retry Options:
README.mdexplaining the newmerge-retriesandmerge-retry-sleepoptions, including usage examples.action.ymlto definemerge-retriesandmerge-retry-sleepas optional inputs with default values (6retries,5000ms sleep).Configuration and Processing Logic:
getConfig()insrc/api.jsto read and parse the newmerge-retriesandmerge-retry-sleepinputs from the action configuration.processPR()insrc/api.jsto implement retry logic for the enqueue operation, using the configured number of retries and sleep interval. [1] [2]