slash-commands: write commit status directly from /lgtm handler
/lgtm was adding the approved label and posting the bot review, but the merge-gate commit status stayed pending forever. Root cause: the status sub-action was designed to react to the labeled/unlabeled events emitted when main.js mutates labels, but main.js writes via GITHUB_TOKEN and GitHub suppresses workflow runs for GITHUB_TOKEN-triggered events. The event cascade never happened. Fix: main.js now calls createCommitStatus directly after each of the four label mutations (/lgtm, /lgtm cancel, /hold, /unhold), computing the new state from the pre-mutation label snapshot so cross-label cases (lgtm while held, unhold while approved) resolve correctly. The status sub-action is reduced to setting pending on open and on push. It no longer reads the approved label at all — that branch is removed, and the approved-label input with it. This closes a bypass: previously anyone with triage permissions could manually add the approved label, and on the resulting labeled event the sub-action would set success. Now the only success writer is the auth-gated /lgtm path. Caller workflows should trim pull_request_target types to [opened, synchronize]. The labeled/unlabeled/reopened triggers are dead weight: labeled/unlabeled never fired for bot writes, and reopened would overwrite a valid success with pending (commit statuses persist on the SHA across close/reopen).
This commit is contained in:
parent
f3ad04958f
commit
332da5ae1a
1 changed files with 85 additions and 53 deletions
|
|
@ -54,6 +54,13 @@ inputs:
|
|||
Set to 'false' to rely on the label alone.
|
||||
required: false
|
||||
default: 'true'
|
||||
status-context:
|
||||
description: >-
|
||||
Commit-status context name written after each label mutation. Must match
|
||||
the status sub-action's status-context so both jobs write to the same
|
||||
check. Mark this context as a required status check in branch protection.
|
||||
required: false
|
||||
default: slash-commands/approval
|
||||
stageblog-workflow:
|
||||
description: >-
|
||||
Workflow file name (e.g. stage-blog.yml) to dispatch when /stageblog is
|
||||
|
|
@ -93,6 +100,7 @@ runs:
|
|||
CODEOWNERS_PATH: ${{ inputs.codeowners-path }}
|
||||
INVALIDATE_ON_PUSH: ${{ inputs.invalidate-on-push }}
|
||||
SUBMIT_REVIEW: ${{ inputs.submit-review }}
|
||||
STATUS_CONTEXT: ${{ inputs.status-context }}
|
||||
STAGEBLOG_WORKFLOW: ${{ inputs.stageblog-workflow }}
|
||||
STAGEBLOG_PATHS: ${{ inputs.stageblog-paths }}
|
||||
ORG_TOKEN: ${{ inputs.github-token }}
|
||||
|
|
|
|||
Loading…
Reference in a new issue