Skip to content

feat: update draft PR comment when release is published#98

Open
joshjohanning wants to merge 5 commits into
mainfrom
feat/update-draft-comment-on-publish
Open

feat: update draft PR comment when release is published#98
joshjohanning wants to merge 5 commits into
mainfrom
feat/update-draft-comment-on-publish

Conversation

@joshjohanning
Copy link
Copy Markdown
Owner

Closes #94

Summary

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

src/index.js

  • handleReleasePublished() — New handler that searches recent merged PRs for draft reminder comments and updates them to show "✅ Release Published" state
  • buildDraftReminderBody() / buildPublishedReminderBody() — Builder functions for draft and published comment bodies
  • DRAFT_COMMENT_MARKER_PREFIX — Version-specific HTML marker for reliable comment matching
  • Release event routingrun() detects release.published events and routes to the handler with early return (no package.json read, no git ops)
  • Refactored existing draft reminder to use buildDraftReminderBody() with marker
  • Author filtering — Only updates comments posted by the authenticated user
  • Legacy fallback — Detects old comments without markers via heading + version match
  • Idempotency — Skips if comment already shows published state
  • Predictable URL — Constructs tag-based URL (draft untagged-... URLs 404 after publishing)

action.yml

  • Updated draft_release_pr_reminder description to mention update-on-publish behavior

README.md

  • Updated input table description
  • Added "Draft Release PR Reminder" section with trigger example

__tests__/index.test.js

  • 13 new tests covering: event routing, early return contract, marker matching, legacy fallback, author filtering, auth failure, idempotency, predictable URL, API errors, skip conditions

Version bump

  • 3.1.23.2.0 (new feature)

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
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.published routing 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 to 3.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

Comment thread src/index.js Outdated
Comment thread src/index.js Outdated
Comment thread src/index.js Outdated
- 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
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.published routing 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

Comment thread action.yml Outdated
Comment thread README.md Outdated
Comment thread src/index.js Outdated
- 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
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.published event 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.23.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 failed issues.updateComment (e.g., due to permission/ownership mismatch) will throw into the outer try and 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

Comment thread src/index.js Outdated
Comment thread README.md Outdated
Comment thread __tests__/index.test.js
…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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update draft release PR comment when release is published

2 participants