Skip to content

Add changelog/comment composite and release-notes-comments reusable workflow - #323

Merged
Mpdreamz merged 5 commits into
mainfrom
feature/changelog-pr-comment-part2
Sep 1, 2026
Merged

Mpdreamz merged 5 commits into
mainfrom
feature/changelog-pr-comment-part2

Conversation

@Mpdreamz

@Mpdreamz Mpdreamz commented Sep 1, 2026

Copy link
Copy Markdown
Member

Repos using changelog-validate now upload a changelog-decision artifact on every PR run. Repos that want the sticky PR comment opt in by copying one workflow_run trigger workflow that calls the new release-notes-comments.yml reusable workflow.

Affects: Release notes, Automation

Why

validate-labels and evaluate-pr in docs-builder now write a decision-metadata file on CI (merged in elastic/docs-builder#3993). The metadata travels across the workflow_run boundary as an artifact so a job with pull-requests: write can post the comment without the triggering event needing write access. Fork PRs have the same problem: GitHub forces the token read-only on pull_request from a fork, so commenting must happen in a separate workflow_run job. This PR is the docs-actions half — it uploads the artifact and provides the comment composite and reusable workflow.

What

Fork-context flags passed to evaluate-pr

The changelog/validate composite gains four new env vars (IS_FORK, MAINTAINER_CAN_MODIFY, HEAD_REPO, computed from pull_request event fields) and maps them to --is-fork, --can-commit, --maintainer-can-modify, --head-repo flags. can-commit is true for same-repo PRs; for forks it requires maintainer_can_modify. These fields travel into metadata.json so the comment renderer can choose the right guidance variant.

Artifact upload in changelog/validate

A new Upload decision artifact step runs if: always() at the end of the composite, uploading .artifacts/changelog-decision as changelog-decision with one-day retention and if-no-files-found: ignore. The if: always() means a failing gate (missing label) still uploads — the comment job needs the metadata to explain what is missing.

changelog/comment composite

Downloads changelog-decision cross-run using github.event.workflow_run.id, sets up docs-builder, and runs changelog github-comment --metadata /tmp/changelog-decision/metadata.json. Follows the same check-then-download guard as vale/report to handle cancelled upstream runs gracefully.

release-notes-comments.yml reusable workflow

Triggered via workflow_call (callers use workflow_run on their upstream workflows). Runs the changelog/comment composite with pull-requests: write and contents: none. Concurrency is keyed on the repo + branch with cancel-in-progress: false — two upstream workflows can land close together, and cancelling mid-upsert risks leaving the wrong comment body.

Verify

Copy this trigger workflow into a test repo's default branch and open a PR with no changelog type label:

# .github/workflows/release-notes-comments.yml
name: Changelog PR comments

on:
  workflow_run:
    workflows: ["Release notes"]
    types: [completed]

jobs:
  comment:
    uses: elastic/docs-actions/.github/workflows/release-notes-comments.yml@main
    permissions:
      pull-requests: write

A sticky ### 📋 Changelog comment should appear on the PR naming the missing label. Adding the label and pushing should edit the same comment to the resolved body.

Stack: 2 of 4, on top of elastic/docs-builder#3993. PR 3 strips the JS from submit/apply (coordinated with elastic/cloud). PR 4 drops should-comment-success / should-comment-failure from docs-builder.

Out of scope: changelog/submit is not touched. submit/apply still posts via its existing JS steps. The two implementations converge on one comment during the overlap window — the sticky-comment identity guarantee (marker at end, ### 📋 Changelog prefix first) was established in PR 1.

Mpdreamz and others added 4 commits August 18, 2026 18:35
The reusable PR-review workflow's conclusion and safe_outputs jobs
request issues:write for failure and no-op run tracking, but this
workflow granted only issues:read. GitHub rejects the permission
escalation before any job starts, so the workflow's own review of
this PR flagged the same gap for discussions:write. Both are now
granted.

Also suppress actionlint's false-positive "unknown permission scope
copilot-requests" — the scope is valid at GitHub Actions runtime,
actionlint just doesn't recognize it yet.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
…orkflow

validate now passes fork-context flags (--is-fork, --can-commit,
--maintainer-can-modify, --head-repo) to evaluate-pr and uploads the
decision artifact with if: always() so a downstream workflow_run job can
post the sticky PR comment on both success and failure paths.

The new changelog/comment composite downloads the cross-run artifact and
runs changelog github-comment. The release-notes-comments.yml reusable
workflow wires the workflow_run trigger to the composite with
pull-requests: write and cancel-in-progress: false.

Co-Authored-By: Claude <noreply@anthropic.com>
@Mpdreamz
Mpdreamz requested a review from a team as a code owner September 1, 2026 15:30
@Mpdreamz Mpdreamz added the enhancement New feature or request label Sep 1, 2026
@Mpdreamz
Mpdreamz requested a review from technige September 1, 2026 15:30
Co-Authored-By: Claude <noreply@anthropic.com>
@Mpdreamz
Mpdreamz merged commit 875fd30 into main Sep 1, 2026
10 checks passed
@Mpdreamz
Mpdreamz deleted the feature/changelog-pr-comment-part2 branch September 1, 2026 15:47
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.

1 participant