name: "Contributor License Agreement"

on:
  issue_comment:
    types: [created]
  pull_request_target:
    types: [opened, closed, synchronize]

permissions:
  actions: write
  contents: write
  pull-requests: write
  statuses: write

jobs:
  cla-assistant:
    runs-on: ubuntu-latest
    steps:
      - name: "Run CLA Assistant"
        if: >
          (github.event_name == 'pull_request_target') ||
          (github.event_name == 'issue_comment' && github.event.issue.pull_request && 
          (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA'))
        uses: contributor-assistant/github-action@v2.6.1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          path-to-signatures: 'signatures/cla.json'
          path-to-document: 'https://github.com/${{ github.repository }}/blob/main/CLA.md'
          branch: 'cla-signatures'
          allowlist: 'saifmukhtar,bot*,*[bot],dependabot*,github-actions*'
          
          custom-notsigned-prcomment: |
            Thank you for your pull request! 
            
            Before we can merge your contribution, please review and accept our [Contributor License Agreement (CLA)](https://github.com/${{ github.repository }}/blob/main/CLA.md).
            
            You can sign the CLA by posting a comment on this pull request with the exact text:
            ```text
            I have read the CLA Document and I hereby sign the CLA
            ```
          custom-allsigned-prcomment: '✅ All contributors have signed the OpenAVX Contributor License Agreement. Thank you!'
