Skip to content
Latchkey

How to Use slash-command-dispatch in GitHub Actions

slash-command-dispatch reads a comment, validates the command, and re-emits it as a repository_dispatch event that a separate command workflow handles.

Run peter-evans/slash-command-dispatch in a command dispatcher workflow. It parses /command comments, enforces a permission floor, reacts to the comment, and dispatches to a handler workflow.

Steps

  • Add a dispatcher workflow on issue_comment.
  • List allowed commands and set a permission floor.
  • The action fires a repository_dispatch per command.
  • Handle each command in a repository_dispatch workflow.

Dispatcher workflow

.github/workflows/ci.yml
on:
  issue_comment:
    types: [created]
jobs:
  dispatch:
    runs-on: ubuntu-latest
    steps:
      - uses: peter-evans/slash-command-dispatch@v4
        with:
          token: ${{ secrets.PAT }}
          permission: write
          commands: |
            deploy
            retest
          issue-type: pull-request

Gotchas

  • The permission input rejects users below the floor automatically, but keep it explicit at write or higher for deploys.
  • A PAT (not GITHUB_TOKEN) is required so the dispatched event can start a new workflow.
  • Only commands you list are dispatched; unknown commands are ignored.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →