name: 'CLA Assistant'
on:
  pull_request_target:
    types: [opened, synchronize]

permissions:
  pull-requests: write

jobs:
  check:
    name: 'Check'
    runs-on: ubuntu-latest
    steps:
      - id: check
        uses: directus/cla-bot@v0.0.1
      - if: failure() && steps.check.outputs.missing
        uses: marocchino/sticky-pull-request-comment@v2
        with:
          message: |
            Hi ${{steps.check.outputs.missing}}!

            Thank you for contributing to Directus! Before we consider your Pull Request, we ask that you sign [our Contributor License Agreement (CLA)](https://github.com/directus/directus/blob/main/cla.md). This is only required for your first Pull Request.

            Please [review the CLA](https://github.com/directus/directus/blob/main/cla.md), and sign it by adding your GitHub username to [the contributors.yml file](https://github.com/${{github.event.pull_request.head.repo.full_name}}/blob/${{github.head_ref}}/contributors.yml). Thanks!
      - if: success()
        uses: marocchino/sticky-pull-request-comment@v2
        with:
          delete: true
