name: Code Review

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

concurrency:
  group: ${{ github.workflow }}-${{ github.event.inputs.pullNumber || github.event.number }}
  cancel-in-progress: true

jobs:
  code_review:
    runs-on: ubuntu-20.04
    timeout-minutes: 30
    steps:
      - name: 👀 Checkout
        uses: actions/checkout@v3
      - name: ➕ Add `bin` to GITHUB_PATH
        run: echo "$(pwd)/bin" >> $GITHUB_PATH
      - name: ♻️ Restore caches
        uses: ./.github/actions/expo-caches
        with:
          yarn-tools: 'true'
      - name: 🔬 Reviewing a pull request
        run: expotools code-review --pr ${{ github.event.inputs.pullNumber || github.event.number }}
        env:
          GITHUB_TOKEN: ${{ secrets.EXPO_BOT_GITHUB_TOKEN }}
