name: Contribution Policy

on:
  workflow_dispatch:
    inputs:
      pr:
        description: PR number or all
        required: true
        default: all
        type: string
      dry_run:
        description: Dry run
        required: true
        default: true
        type: boolean
  pull_request_target:
    types:
      - opened
      - edited
      - reopened
      - synchronize
      - ready_for_review
      - labeled
      - unlabeled

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

jobs:
  check:
    name: Check contribution policy
    runs-on: ubuntu-latest
    steps:
      - name: Checkout policy script
        uses: actions/checkout@v4
        with:
          ref: ${{ github.event.pull_request.base.sha || github.ref }}
          fetch-depth: 1

      - name: Check contribution policy
        uses: actions/github-script@v7
        with:
          script: |
            const { run } = require("./.github/scripts/check-contribution-policy.js");
            await run({ github, context, core });
