# Write comments "/ok-to-test sha=<hash>" on a pull request. This will emit a repository_dispatch event.
name: Ok To Test

on:
  issue_comment:
    types: [created]

jobs:
  ok-to-test:
    runs-on: ubuntu-latest
    permissions:
      pull-requests: write # For adding reactions to the pull request comments
      contents: write # For executing the repository_dispatch event
    # Only run for PRs, not issue comments
    if: ${{ github.event.issue.pull_request }}
    steps:
      - name: Slash Command Dispatch
        uses: peter-evans/slash-command-dispatch@v5
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          reaction-token: ${{ secrets.GITHUB_TOKEN }}
          issue-type: pull-request
          commands: ok-to-test
          # The repository permission level required by the user to dispatch commands. Only allows 1Password collaborators to run this.
          permission: write
