fix: prevent duplicate body template when PR body is modified#20
Open
SetupCoding wants to merge 1 commit intodevindford:mainfrom
Open
fix: prevent duplicate body template when PR body is modified#20SetupCoding wants to merge 1 commit intodevindford:mainfrom
SetupCoding wants to merge 1 commit intodevindford:mainfrom
Conversation
Use includes() instead of startsWith()/endsWith() for duplicate detection. The previous check only matched if the template was at the exact start or end of the body. When a user edits the PR body (adding text before or after the template), the check would fail and the template would be inserted again, creating duplicates. Also updates action runtime from node16 to node24.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes duplicate body template insertion when the PR body has been manually edited by a user.
Problem
The current duplicate detection uses
startsWith()/endsWith()to check if the template is already present in the PR body. This only works if the template remains at the exact start or end of the body.When a user edits the PR body — adding text before a prefixed template or after a suffixed template — the positional check fails and the action inserts the template again, creating duplicates on every subsequent trigger.
Example scenario (prefix mode):
startsWith()check fails → template prepended again ❌ (duplicate)Fix
Replace
startsWith()/endsWith()withincludes()so the duplicate check finds the template regardless of its position within the body.const updateBody = ({ - prefix: !body.toLowerCase().startsWith(inputs.bodyTemplate.toLowerCase()), - suffix: !body.toLowerCase().endsWith(inputs.bodyTemplate.toLowerCase()) + prefix: !body.toLowerCase().includes(inputs.bodyTemplate.toLowerCase()), + suffix: !body.toLowerCase().includes(inputs.bodyTemplate.toLowerCase()) })[inputs.bodyUpdateAction] || false;Additional changes
action.ymlruntime fromnode16tonode24(Node.js 20 deprecation on June 2nd 2026)dist/index.jswith@vercel/ncc