feat: update draft PR comment when release is published#98
Open
joshjohanning wants to merge 5 commits into
Open
feat: update draft PR comment when release is published#98joshjohanning wants to merge 5 commits into
joshjohanning wants to merge 5 commits into
Conversation
When draft_release_pr_reminder is enabled and the workflow includes a release: [published] trigger, the action now automatically updates the original draft reminder comment on the merged PR to show the published state with checked-off next steps and a working release URL. Changes: - Add handleReleasePublished() to detect and update draft comments - Route release.published events in run() with early return - Refactor draft reminder to use buildDraftReminderBody() with marker - Add version-specific HTML marker for reliable comment matching - Support legacy comments via fallback matcher - Use predictable tag URL (draft URLs 404 after publishing) - Author-filter comments to only update our own - Skip already-published comments (idempotency) - Add 13 tests covering all paths - Update README with new section and trigger example - Bump version to 3.2.0
2 tasks
Contributor
There was a problem hiding this comment.
Pull request overview
Adds release-published event handling to keep the “draft release PR reminder” comment accurate after a draft is published, aligning the action’s PR UX with immutable-release workflows (Closes #94).
Changes:
- Add
release.publishedrouting to update the previously-posted draft reminder comment with a published-state message and a stable tag URL. - Refactor reminder comment generation into
buildDraftReminderBody()/buildPublishedReminderBody()with a version-specific marker for matching/idempotency. - Update docs (
action.yml,README.md), add tests for new paths, and bump version to3.2.0.
Show a summary per file
| File | Description |
|---|---|
src/index.js |
Implements release-published handler, marker-based comment matching, and early-return routing for release events. |
__tests__/index.test.js |
Adds coverage for release event routing and comment update behavior. |
action.yml |
Documents the update-on-publish behavior for draft_release_pr_reminder. |
README.md |
Adds user-facing explanation and workflow trigger example for release-publish updates. |
package.json |
Version bump for new feature release. |
package-lock.json |
Lockfile version bump to match package version. |
badges/coverage.svg |
Updates coverage badge after test additions. |
Copilot's findings
- Files reviewed: 5/7 changed files
- Comments generated: 3
- Use strict === 'true' check for draft_release_pr_reminder (consistent) - Add direction: 'desc' to listComments for newest-first ordering - Disable legacy fallback when auth fails (require confirmed author) - Add test for legacy fallback skipped without auth
Contributor
There was a problem hiding this comment.
Pull request overview
Adds release-event handling to keep the “draft release PR reminder” comment accurate after a draft release is published, avoiding broken draft URLs and reflecting completion state.
Changes:
- Added
release.publishedrouting with an early-return path that updates the original draft reminder PR comment. - Introduced builder helpers and a version-tagged HTML marker to reliably match/update the reminder comment (with legacy fallback + idempotency).
- Updated docs/metadata (action input description + README) and expanded Jest coverage; bumped version to
3.2.0.
Show a summary per file
| File | Description |
|---|---|
| src/index.js | Adds release.published handler, comment body builders, marker-based matching, and strict reminder gating. |
| tests/index.test.js | Adds tests for release-event routing, matching/fallback, author filtering, idempotency, and error paths. |
| action.yml | Documents updated reminder behavior for publish events. |
| README.md | Documents the reminder feature and includes workflow trigger example. |
| package.json | Bumps action version to 3.2.0 for the new feature. |
| package-lock.json | Syncs lockfile version metadata to 3.2.0. |
| badges/coverage.svg | Updates coverage badge to reflect new test coverage. |
Copilot's findings
- Files reviewed: 5/7 changed files
- Comments generated: 3
- Replace pulls.list scan with git.getRef + listPullRequestsAssociatedWithCommit - Fix workflow syntax references in action.yml and README descriptions - Update tests to use new API approach
Contributor
There was a problem hiding this comment.
Pull request overview
Adds release-event routing to update the “draft release PR reminder” comment after a release is published, keeping the PR comment accurate and the release link working.
Changes:
- Add
release.publishedevent handling to find and update the original draft reminder PR comment to a “✅ Release Published” state. - Refactor reminder comment construction into
buildDraftReminderBody()/buildPublishedReminderBody()with a version-specific HTML marker for matching/idempotency. - Update docs/tests and bump version to
3.2.0.
Show a summary per file
| File | Description |
|---|---|
src/index.js |
Adds handleReleasePublished() routing + comment body builders + marker-based matching to update draft reminder comments on publish. |
__tests__/index.test.js |
Adds coverage for release-event routing, matching behavior, idempotency, and error paths. |
action.yml |
Updates draft_release_pr_reminder input description to mention update-on-publish behavior. |
README.md |
Documents the draft reminder + publish-update behavior and workflow trigger configuration. |
package.json |
Bumps version 3.1.2 → 3.2.0. |
package-lock.json |
Updates lockfile version fields to match 3.2.0. |
badges/coverage.svg |
Updates coverage badge output. |
Copilot's findings
Comments suppressed due to low confidence (1)
src/index.js:466
- In
handleReleasePublished, a failedissues.updateComment(e.g., due to permission/ownership mismatch) will throw into the outertryand abort the entire scan, even if another PR/comment later in the loop is updatable. Consider handling update failures per-PR/per-comment (catch + continue) so one non-editable match doesn’t prevent updating the correct reminder comment.
await retryWithBackoff(
() =>
octokit.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: markerComment.id,
body: updatedBody
}),
{ retries: 2, baseDelay: 1000, description: `Update comment on PR #${pr.number}` }
);
core.info(`✅ Updated PR comment on PR #${pr.number}`);
return;
}
}
core.info(`No PR comment found with marker for ${version}`);
} catch (error) {
core.warning(`Could not update PR comment: ${error.message}`);
}
- Files reviewed: 5/7 changed files
- Comments generated: 3
…refs - Replace return with continue in loop so all associated PRs get updated - Fix remaining release: [published] reference in README prose - Stricter test assertions using .not.toHaveBeenCalled()
Wrap per-PR logic in its own try/catch so a failed updateComment (e.g., permission/ownership mismatch) logs a warning and continues to the next PR instead of aborting the entire scan. Also fix the 'no comment found' log to only appear when no comments were actually updated (track updatedCount).
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.
Closes #94
Summary
When
draft_release_pr_reminderis enabled and the workflow includes arelease: [published]trigger, the action now automatically updates the original draft reminder comment on the merged PR to show the published state with checked-off next steps and a working release URL.Changes
src/index.jshandleReleasePublished()— New handler that searches recent merged PRs for draft reminder comments and updates them to show "✅ Release Published" statebuildDraftReminderBody()/buildPublishedReminderBody()— Builder functions for draft and published comment bodiesDRAFT_COMMENT_MARKER_PREFIX— Version-specific HTML marker for reliable comment matchingrun()detectsrelease.publishedevents and routes to the handler with early return (no package.json read, no git ops)buildDraftReminderBody()with markeruntagged-...URLs 404 after publishing)action.ymldraft_release_pr_reminderdescription to mention update-on-publish behaviorREADME.md__tests__/index.test.jsVersion bump
3.1.2→3.2.0(new feature)