Skip to content

Commit 593e8fd

Browse files
authored
Add /lgtm and /hold slash-commands workflow (modelcontextprotocol#2381)
Adds a caller workflow for modelcontextprotocol/actions/slash-commands that implements Prow-style PR approval via comment commands: - /lgtm adds 'approved' label + bot APPROVE review - /hold adds 'do-not-merge/hold' label - Both gated by core/lead maintainers OR CODEOWNERS of changed files - New commits invalidate approval automatically The 'status' job is intended to become a required check in branch protection, making the labels an actual merge gate. Requires SLASH_COMMANDS_TOKEN secret (PAT with read:org — see action README for scopes). Also requires the 'approved' and 'do-not-merge/hold' labels to exist. References @slash-commands branch of the actions repo while that PR is open; will bump to @main after it merges. Fixes modelcontextprotocol#2199 🏠 Remote-Dev: homespace
1 parent 8c086ab commit 593e8fd

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Slash Commands
2+
3+
on:
4+
issue_comment:
5+
types: [created]
6+
pull_request_target:
7+
types: [synchronize, opened, reopened, labeled, unlabeled]
8+
9+
permissions:
10+
pull-requests: write
11+
issues: write
12+
contents: read
13+
14+
jobs:
15+
# Parse and execute /lgtm, /hold, /unhold comment commands; invalidate
16+
# approval when new commits are pushed.
17+
handle:
18+
if: >-
19+
(github.event_name == 'issue_comment' && github.event.issue.pull_request) ||
20+
(github.event_name == 'pull_request_target' && github.event.action == 'synchronize')
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: modelcontextprotocol/actions/slash-commands@slash-commands
24+
with:
25+
github-token: ${{ secrets.SLASH_COMMANDS_TOKEN }}
26+
always-allow-teams: core-maintainers,lead-maintainers
27+
28+
# Merge-gate status check — make "Slash Commands / status" a required
29+
# check in branch protection so the labels become enforceable.
30+
status:
31+
if: github.event_name == 'pull_request_target'
32+
runs-on: ubuntu-latest
33+
steps:
34+
- name: Require approval, block on hold
35+
env:
36+
LABELS: ${{ toJson(github.event.pull_request.labels.*.name) }}
37+
run: |
38+
echo "Labels: $LABELS"
39+
if ! jq -e 'contains(["approved"])' <<<"$LABELS" > /dev/null; then
40+
echo "::error::Missing 'approved' label — have a maintainer or CODEOWNER comment /lgtm"
41+
exit 1
42+
fi
43+
if jq -e 'contains(["do-not-merge/hold"])' <<<"$LABELS" > /dev/null; then
44+
echo "::error::'do-not-merge/hold' present — resolve concerns, then comment /unhold"
45+
exit 1
46+
fi
47+
echo "✅ approved and not held"

0 commit comments

Comments
 (0)