name: PR Comment flow
on:
  issue_comment:
    types:
      - created
jobs:
  test:
    if: contains(github.event.comment.body, '/test')
    runs-on: ubuntu-latest
    steps:
      - name: Github API Request
        id: request
        uses: octokit/request-action@v2.0.0
        with:
          route: ${{ github.event.issue.pull_request.url }}
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      - name: Checkout PR Branch
        uses: actions/checkout@v2
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          repository: ${{ fromJson(steps.request.outputs.data).head.repo.full_name }}
          ref: ${{ steps.pr_data.outputs.branch }}
      - uses: actions/setup-node@v2
        with:
          node-version: '14'
          cache: 'yarn'
      - name: Install modules
        run: yarn
      - name: Run tests
        run: yarn test
  lint:
    if: contains(github.event.comment.body, '/test')
    runs-on: ubuntu-latest
    steps:
      - name: Github API Request
        id: request
        uses: octokit/request-action@v2.0.0
        with:
          route: ${{ github.event.issue.pull_request.url }}
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      - name: Checkout PR Branch
        uses: actions/checkout@v2
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          repository: ${{ fromJson(steps.request.outputs.data).head.repo.full_name }}
          ref: ${{ steps.pr_data.outputs.branch }}
      - uses: actions/setup-node@v2
        with:
          node-version: '14'
          cache: 'yarn'
      - name: Install modules
        run: yarn
      - name: Run lint
        run: yarn lint
