name: Code Review

on:
  workflow_dispatch:
    inputs:
      pullNumber:
        description: 'Number of the pull request to review'
        required: true
  pull_request_target:
    branches: [master, sdk-*]

concurrency:
  group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  code_review:
    runs-on: ubuntu-18.04
    steps:
      - name: 👀 Checkout
        uses: actions/checkout@v2
      - name: ♻️ Restore node modules in tools
        uses: actions/cache@v2
        id: tools-modules-cache
        with:
          path: tools/node_modules
          key: ${{ runner.os }}-tools-modules-${{ hashFiles('tools/yarn.lock') }}
          restore-keys: |
            ${{ runner.os }}-tools-modules-
      - name: 🔬 Reviewing a pull request
        run: bin/expotools code-review --pr ${{ github.event.inputs.pullNumber || github.event.number }}
        env:
          GITHUB_TOKEN: ${{ secrets.EXPO_BOT_GITHUB_TOKEN }}
