feat(action): render PR comment to file and expose path output#38
Merged
Conversation
Adds scripts/render_comment.py which reads check outcomes / outputs
from environment variables and prints the validation-results
Markdown body to stdout. Reading from env vars (rather than passing
values via ${{ steps.X.outputs }} interpolation in YAML) avoids
escaping issues with multi-line tool output, embedded backticks, and
heredoc EOF markers.
action.yml:
* adds a Render comment markdown step (id: render) that runs the
new script and writes its output to
${{ runner.temp }}/validation-comment.md
* exposes that path via a new comment_path output
* switches the existing Post PR comment step from inline message:
to path: (reading from the same file)
Default behaviour is unchanged for callers using post_comment: 'true'
on same-repo PRs — the comment is still posted by the same
marocchino/sticky-pull-request-comment@v2 step. The new output
enables a follow-up workflow_run companion in the integrations repo
to post the comment for fork PRs, where the pull_request token is
read-only.
Closes #37
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 #37.
What
Renders the validation-results PR comment Markdown body to a file (
${{ runner.temp }}/validation-comment.md) and exposes the path via a newcomment_pathaction output. The existingPost PR commentstep now reads from that file via marocchino'spath:input instead of an inlinemessage:block.This is the tooling-repo half of the fix for fork PRs not getting validation-results comments. The follow-up consumer-repo PR in
autohive-ai/autohive-integrationswill setpost_comment: 'false', upload the rendered file as an artifact, and add aworkflow_run-triggered companion workflow that posts the comment from the base-repo context (where theGITHUB_TOKENactually haspull-requests: writeeven for fork PRs).Why
pull_requestworkflows triggered from forks always run with a read-onlyGITHUB_TOKENregardless of the workflow'spermissions:block (docs). So the existing inline comment step always 403s on fork PRs and the job conclusion goes ❌ even when all five validation checks passed. Concrete example: autohive-ai/autohive-integrations#293 (HubSpot tasks, opened fromlohitya/autohive-integrations).The standard fix is the two-workflow pattern, which needs the comment body to be available as a file (otherwise the consumer workflow has to duplicate the entire ~40-line template). Hence this change.
Files
scripts/render_comment.py(new) — reads check outcomes / outputs from env vars and prints the Markdown body to stdout. Using env vars rather than${{ steps.X.outputs }}YAML interpolation avoids escaping issues with multi-line tool output, embedded backticks, andEOFmarkers.action.yml:Render comment markdownstep (id: render) that runs the new script and writes to${{ runner.temp }}/validation-comment.md.comment_pathoutput exposing that path.Post PR commentstep from inlinemessage:topath:(reads from the same file).Backward compatibility
Strictly additive:
post_comment: 'true'(same-repo PRs) is unchanged — the samemarocchino/sticky-pull-request-comment@v2step posts the same comment, just reading the body from a file instead of an inline string.@v2continue to work without changes when thev2tag is moved to the merge commit.Verification
python3 -c "import yaml; yaml.safe_load(open('action.yml'))"— YAML parses cleanly.render_comment.pysmoke-tested locally with multi-line / embedded-EOF/ backtick payloads — produces the expected Markdown.Out of scope (follow-up PR in
autohive-integrations)post_comment: 'false'and uploading the rendered file as an artifact invalidate-integration.yml.validate-integration-comment.yml(theworkflow_runcompanion that downloads the artifact and posts the comment from base-repo context).v2after this PR merges.