Repository navigation
Add a shared pull request comment action - #18
Conversation
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
| | `operation` | `upsert` | `upsert`, `create`, `update`, `delete` or `find` | | ||
| | `marker` | empty | Hidden first line that finds the comment. Needed for `upsert` and `find`. For `update` and `delete` it finds the comment when there is no `comment-id` | | ||
| | `body` | empty | The comment text. Give `body` or `body-file`, not both | | ||
| | `body-file` | empty | Path of a file that holds the comment text. Prefer it for long text | |
There was a problem hiding this comment.
Took me some investigation to realize why we need this.
It is to avoid this on a caller, which is gross. I was hoping that we could expect callers to just cat the file directly into body but it would require a whole setup before it which is very inconvenient when they may have a boilerplate comment that gets added to every PR or similar.
- id: text
run: |
{
echo 'body<<EOF'
cat result.md
echo 'EOF'
} >> "$GITHUB_OUTPUT"
- uses: ./.github/actions/pr-comment
with:
body: ${{ steps.text.outputs.body }}There was a problem hiding this comment.
Thanks. The README now has a "Body from a file" section that shows the extra step callers would need without it (6a9f678).
Adds
.github/actions/pr-comment, one place for the pull request comment operations other actions need: find, create, update, delete, and "replace the comment that starts with this marker, or create it".Why
Third-party comment actions on floating tags can change under us, and they hold a token that can write. This calls the GitHub API through
actions/github-script, which every action here already uses. It is tested with the real Octokit and a replaced network, like the other actions.Use
From a workflow step (
$/.github/actions/pr-commentinside this repository), or from another action's script (require('../pr-comment/pr-comment.js')).pull-requests: write, or skip forks.The README has the inputs, the outputs and the rules.
Next
#14 (Plugin Check) and #15 (Playground preview) will use it, and will be stacked on this branch.
Tests
npm install, thennode --test. This also changes the test helper so a rule can answer 204, which a delete does.Summary by CodeRabbit