Skip to content

GitHub Action: post sticky PR comment with coverage/drift summary #119

Description

@bjcorder

Problem

The GitHub Action uploads artifacts and SARIF, but the signal reviewers act on — "this PR added an unauthenticated route" / "coverage class changed on 3 routes" — is buried in artifacts or the code-scanning tab. A sticky PR comment with the drift/coverage summary puts authorization changes in front of reviewers where approval decisions happen, which is the tool's core review loop.

Current behavior

  • action.yml supports scan, baseline compare, artifact upload, and SARIF upload; there is no PR comment output. The Markdown renderer already produces exactly the right content (drift summary, coverage counts, per-route sections) via authmap diff / scan Markdown output.

Proposed implementation

  1. New action inputs
    • pr-comment (default false), pr-comment-mode (drift — only when drift/gating findings exist — or always), optional github-token input defaulting to ${{ github.token }}.
  2. Sticky comment upsert
    • Composite-action step (bash + gh api, consistent with the existing action style — no new Rust code): render/reuse the Markdown summary, wrap with a hidden marker (<!-- authmap-summary -->), then find-and-update the existing marked comment or create one (standard sticky-comment pattern). Truncate to GitHub's comment size limit with a link to the full artifact when the summary is large.
    • Skip gracefully (with a log line, not a failure) when not in a pull_request context or when the token lacks permission.
  3. Docs
    • docs/GITHUB_ACTION.md: document the inputs, the required pull-requests: write permission block, a full workflow example combining baseline + diff + comment, and the privacy note that route paths from the repo are posted to the PR thread (consistent with docs/DATA_HANDLING.md posture — content stays within the repo's own PR).

Acceptance criteria

  • With pr-comment: true on a PR with drift, exactly one comment appears and is updated in place on subsequent pushes (no comment spam).
  • drift mode posts nothing on a clean PR; always mode posts the summary regardless.
  • Missing permissions/non-PR context logs a warning and does not fail the job.
  • Oversized summaries truncate with an artifact link.
  • Action integration test (or a documented manual verification workflow on a test PR) + docs/GITHUB_ACTION.md updated; CHANGELOG entry.

References

  • action.yml (existing inputs/steps)
  • docs/GITHUB_ACTION.md, docs/DATA_HANDLING.md
  • Markdown drift summary: authmap diff output (crates/authmap-report)

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:ciContinuous integration and GitHub Actions workflowsarea:reportingJSON, Markdown, SARIF, GitHub summaries, and explain outputenhancementNew feature or requestgithub-actionsGitHub Actions and CI automation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions