Skip to content

Post changelog-file PR comments from the same run - #439

Merged
theletterf merged 3 commits into
mainfrom
feature/changelog-comment-same-run
Oct 26, 2026
Merged

theletterf merged 3 commits into
mainfrom
feature/changelog-comment-same-run

Conversation

@theletterf

Copy link
Copy Markdown
Member

This finishes what #324 set out to do. docs-builder#3995 landed today ahead of #324 and silently stopped two changelog comments, and #438 patched the conditions so the JS steps work again. #324 itself can't land: it uploads a changelog-decision artifact from the "Changelog file" run, but the workflow_run comments callers skip that run (the pull_request guard from #325), and the newest-run lookup from #422 can't resolve its PR. The full analysis is in elastic/docs-eng-team#1131.

Instead of handing the decision to another workflow, this PR posts it from a job in the same run. "Changelog file" already runs from workflow_run with a write token, so the fork-token problem behind the cross-run path doesn't apply, and a separate job still takes pull-requests: write off the commit job.

changelog/submit/apply loses the three github-script steps, the four JS scripts, and the config input. It runs changelog github-decision and uploads changelog-decision, but only where the JS commented: committed, commit failed, comment-only, and no-label. That matters because github-comment deletes the sticky comment for a success with no body, so recording a decision on every run (as #324 did) would delete comments on early stops and on a second push with nothing new to commit. github-decision exits 0 when it can't read the metadata, so the step checks that an outcome was written before it uploads. A new decision-uploaded output tells the workflow whether to comment.

changelog/comment gets a current-run input that downloads the artifact from the current run instead of resolving the triggering one.

release-notes-changelog-file.yml and changelog-submit.yml get a comment job with pull-requests: write only, and apply drops to pull-requests: read. The fork-guidance decision from #349 goes through the same job, which should also make that comment appear; I haven't traced a run to confirm it's broken today. changelog-submit.yml changes because it calls apply@v1 and would otherwise stop commenting at the next release; only docs-eng-playground uses it.

No consumer repo needs a change.

Testing

pre-commit passes (actionlint, action-readme). I built docs-builder from main and ran github-decision on sample metadata for committed, failed, and none; each wrote the expected outcome. The staging metadata from prepare-artifact has no gate, so the comment-only and labels-needed bodies render (ChangelogGithubCommentService.cs lines 215 and 258).

Not tested yet: an end-to-end run. workflow_run workflows run from the default branch, so the test needs the docs-playground-release-notes-changelogs caller pointed at this branch, and this workflow's own uses: refs to apply and comment pointed here too, then both reverted before merge. Cases: committed, second push, comment-only, commit failed, no-label, an early stop, and the race with the check run's comment job. It stays a draft until that's done.

After merge: publish a release to move v1, then close #324.

Related to elastic/docs-eng-team#1131

🤖 Generated with Claude Code

Remove the github-script comment steps and JS scripts from
changelog/submit/apply. The action now records the decision with
changelog github-decision and uploads it as changelog-decision, only in
the cases where the JS steps commented: committed, commit failed,
comment-only, and no-label.

A new comment job in release-notes-changelog-file.yml and
changelog-submit.yml posts the comment from that artifact through
changelog/comment with the new current-run input. The apply job drops
to pull-requests: read. The fork-guidance decision uses the same job.

Related to elastic/docs-eng-team#1131. Replaces #324.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@theletterf theletterf added the enhancement New feature or request label Oct 26, 2026
@theletterf

Copy link
Copy Markdown
Member Author

I ran this end to end in docs-playground-release-notes-changelogs, with the caller and this workflow's own uses: refs pointed at the branch for about 15 minutes. Both are back to @v1 now (the TEMP commit is reverted, and the playground caller is restored).

What I saw, per case:

  • Committed (playground#19, enhancement, no file): the entry was committed and the new comment job updated the sticky comment to the "entry committed" body. The commit job ran with pull-requests: read.
  • Commit failed: I got this one for free. Opening the PR with a label fires two check runs, so two changelog-file runs raced on the same branch. One push was rejected (cannot lock ref), that run recorded failed and posted the commit-failed body, and the other run's "committed" body replaced it a few seconds later. The same race exists with the JS steps today, since they also post on steps.commit.outcome == 'failure', so this isn't new, but the final comment depends on which job finishes last.
  • Second push (playground#19): "No changes to commit", no decision recorded, the comment job was skipped. The sticky comment was then deleted by the check run's comments workflow ("PR Move concurrency to workflow level to ensure order #19 is proceed — deleting stale failure comment"). That's not new either: the C# lookup also matches the ### 📋 Changelog title the JS comment starts with.
  • Comment-only (playground#22, comment-only: true in the caller): the generated entry was posted as a comment, nothing was committed.
  • Skip (playground#21, changelog:skip): evaluate-artifact stopped early ("Labels changed since generate, all products blocked"), nothing was recorded, and the comment job was skipped. So this also covers the early-stop case.
  • No label (playground#20): generate fails on a missing label, so apply never runs and the label-needed comment comes from the check run's comments workflow. Same as today.

One real bug turned up, in docs-builder rather than here: the "entry committed" links repeat the repo name (github.com/elastic/docs-playground-release-notes-changelogs/elastic/docs-playground-release-notes-changelogs/blob/...). ChangelogGithubCommentService passes metadata.HeadRepo, which is owner/repo, as both the owner and the repo to RenderEntryCommitted. I'm keeping this PR in draft until that fix is out, otherwise every committed comment gets a broken link.

Not tested: the fork-guidance path, because it needs a fork PR from a non-member.

@theletterf
theletterf marked this pull request as ready for review October 26, 2026 16:31
@theletterf
theletterf requested a review from a team as a code owner October 26, 2026 16:31
@theletterf
theletterf requested a review from Mpdreamz October 26, 2026 16:31
SKIP_LABELS: ${{ steps.meta.outputs.skip-labels }}
CONFIG_FILE: ${{ inputs.config }}
# The comment renderer shows the generated entry in comment-only mode
GENERATED=$(ls /tmp/changelog-staging/*.yaml 2>/dev/null | head -1)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Severity: P2 (Medium)

Allow the YAML lookup to succeed when no entry was generated. For no-label, staging contains metadata but no YAML, so ls exits nonzero. With this step's Bash -e -o pipefail, the assignment terminates the step before github-decision runs. Because the failure is continued and the upload requires a successful decision step, no missing-label comment is posted—the exact failure path this condition is meant to preserve.

Generated by Libra. React with 👍 or 👎 to give feedback on this comment.

@theletterf
theletterf merged commit 52bd814 into main Oct 26, 2026
5 checks passed
@theletterf
theletterf deleted the feature/changelog-comment-same-run branch October 26, 2026 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants