# Docs: https://github.com/sturdy-dev/codeball-action
name: Codeball
on: [ pull_request ]

permissions:
  contents: read
  issues: write
  pull-requests: write

jobs:
  codeball:
    runs-on: ubuntu-latest
    name: Codeball
    steps:

      # Start a new Codeball review job
      # This step is asynchronous and will return a job id
      - name: Trigger Codeball
        id: codeball_baller
        uses: sturdy-dev/codeball-action/baller@v2


      # Wait for Codeball to return the status
      - name: Get Status
        id: codeball_status
        uses: sturdy-dev/codeball-action/status@v2
        with:
          codeball-job-id: ${{ steps.codeball_baller.outputs.codeball-job-id }}

      # If Codeball approved the contribution, approve the PR
      - name: Approve PR
        uses: sturdy-dev/codeball-action/approver@v2
        if: ${{ steps.codeball_status.outputs.approved == 'true' }}
        with:
          message: "Codeball: LGTM! :+1:"
