on:
  pull_request_target:                                     

jobs:
  is-collaborator:
    runs-on: ubuntu-latest
    steps:
      - name: Get User Permission
        id: checkAccess
        uses: actions-cool/check-user-permission@cd622002ff25c2311d2e7fb82107c0d24be83f9b
        with:
          require: write
          username: ${{ github.actor }}
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      - name: Check User Permission
        if: steps.checkAccess.outputs.require-result == 'false'
        run: |
          echo "${{ github.actor }} does not have permissions on this repo."
          echo "Current permission level is ${{ steps.checkAccess.outputs.user-permission }}"
          exit 1
  build:
    needs: is-collaborator
    uses: TestOrg/TestRepo/.github/workflows/build_nested.yml@main
    with:
      COMMIT_SHA: ${{ github.event.pull_request.head.sha }} # shouldn't alert since permission check
