name: PR Checklist

on:
  pull_request:
    types: [opened, edited, synchronize]

jobs:
  check-pr:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Check PR description
        uses: actions/github-script@v7
        with:
          script: |
            const body = context.payload.pull_request.body || '';
            const required = ['Description', 'Test Plan', 'Checklist'];
            const missing = required.filter(r => !body.includes(r));

            if (missing.length > 0) {
              core.setFailed(`PR description missing: ${missing.join(', ')}`);
            }

  auto-assign:
    runs-on: ubuntu-latest
    steps:
      - name: Auto-assign PR
        uses: actions/github-script@v7
        with:
          script: |
            github.rest.issues.addAssignees({
              owner: context.repo.owner,
              repo: context.repo.repo,
              issue_number: context.issue.number,
              assignees: [context.payload.pull_request.user.login]
            });
