name: e2e

on:
  issue_comment:
    types: [created]

permissions:
  contents: read
  pull-requests: write

jobs:
  ack:
    if: github.event.issue.pull_request && github.event.comment.body == '/e2e'
    runs-on: ubuntu-latest
    steps:
      - name: Acknowledge
        env:
          GH_TOKEN: ${{ github.token }}
          NUMBER: ${{ github.event.issue.number }}
        run: gh pr comment "$NUMBER" --repo "$GITHUB_REPOSITORY" --body "Queued"
      - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
        with:
          ref: refs/pull/${{ github.event.issue.number }}/merge
          persist-credentials: false
      - name: Run the end-to-end suite
        env:
          E2E_TOKEN: ${{ secrets.E2E_TOKEN }}
        run: |
          npm ci
          npm run e2e
