-
Notifications
You must be signed in to change notification settings - Fork 1
feat(seidroid-review): acknowledge the trigger with a reaction #72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -577,6 +577,9 @@ jobs: | |
| pull-requests: write # upsert the one sticky verdict comment | ||
| contents: read # read PR metadata | ||
| checks: write # publish the review check run | ||
| # React to the triggering comment. A reaction on a PR comment goes to the | ||
| # ISSUE comments endpoint, which pull-requests: write does not cover. | ||
| issues: write # acknowledge the trigger with a reaction | ||
| # The credential lives ONLY here, at job level. It must never be re-declared | ||
| # as step-level env on a `uses:` step (composite/action steps do not receive | ||
| # step-level env at all) -- that is the exact defect that broke every real | ||
|
|
@@ -594,6 +597,36 @@ jobs: | |
| # happens here, the same way the machine-client check below does it. | ||
| HAS_REVIEWER_IDENTITY: ${{ secrets.SEIDROID_APP_ID != '' }} | ||
| steps: | ||
| # First, deliberately: the reaction is the only signal the trigger was | ||
| # seen, and everything after it -- toolchain, driver install, session | ||
| # start -- runs for minutes before anything else appears on the pull | ||
| # request. An acknowledgement that arrives after the verdict is not one. | ||
| # | ||
| # Comment path only. An automatic pull_request review has no comment to | ||
| # react to, so the guard leaves comment_id empty and this is skipped. | ||
| # | ||
| # continue-on-error: an acknowledgement is a courtesy. Failing the review | ||
| # because a reaction did not post would trade the whole job for the | ||
| # signal that the job started. | ||
| - name: Acknowledge the trigger | ||
| if: ${{ needs.guard.outputs.comment_id != '' }} | ||
| continue-on-error: true | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [nit] The reaction lands as Not a straightforward fix, and reasonable to leave as is: the App token is scoped to |
||
| REPO: ${{ github.repository }} | ||
| TRIGGER_ID: ${{ needs.guard.outputs.comment_id }} | ||
| run: | | ||
| set -euo pipefail | ||
| # Reactions are idempotent per (user, content): re-running a review on | ||
| # the same comment returns the existing reaction rather than adding a | ||
| # second one, so a retry needs no cleanup. | ||
| if gh api -X POST "repos/$REPO/issues/comments/$TRIGGER_ID/reactions" \ | ||
| -f content=eyes >/dev/null 2>&1; then | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [suggestion] Capturing stderr and folding it into the warning keeps that, e.g.: if err=$(gh api -X POST "repos/$REPO/issues/comments/$TRIGGER_ID/reactions" \
-f content=eyes 2>&1 >/dev/null); then
echo "acknowledged comment $TRIGGER_ID"
else
echo "::warning::could not react to comment $TRIGGER_ID; the review continues: $(printf '%s' "$err" | tr '\n' ' ')"
fiThe |
||
| echo "acknowledged comment $TRIGGER_ID" | ||
| else | ||
| echo "::warning::could not react to comment $TRIGGER_ID; the review continues" | ||
| fi | ||
|
|
||
| - name: Set up Go | ||
| uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 | ||
| with: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[suggestion] This is a reusable workflow, so the caller's token is the ceiling: a called job may only downgrade the caller's permissions, never elevate them. Where the calling job enumerates its
permissions:(as every workflow in this repo does) withoutissues: writeβ or where the org restricts the default GITHUB_TOKEN β GitHub rejects the request rather than intersecting it, failing the wholereviewjob before any step runs (The workflow is requesting 'issues: write', but is only allowed 'issues: none'). The step'scontinue-on-errorcannot protect against that, because the failure is workflow validation, not the step.The effect is the inverse of the change's purpose: a caller that bumps the pin without also adding the permission loses the entire review, not just the acknowledgement. Worth confirming sei-load#97 adds
issues: writeto the caller job and lands with the bump, and worth stating the new caller requirement in this file's header alongside the other caller-facing wiring.