diff --git a/.github/workflows/triage_add_to_project.yml b/.github/workflows/triage_add_to_project.yml index 4dcf519a2a1..2a5f775d378 100644 --- a/.github/workflows/triage_add_to_project.yml +++ b/.github/workflows/triage_add_to_project.yml @@ -12,9 +12,25 @@ jobs: add-to-triage-project: name: Add to triage project runs-on: ubuntu-latest + env: + PROJECT_NUMBER: 9 + GITHUB_TOKEN: ${{ secrets.ADD_TO_PROJECT_TOKEN }} steps: - - uses: actions/add-to-project@v0.3.0 + - name: is-collaborator + run: | + gh api graphql -f query=' + query($org: String!, $repo: String!, $user: String!) { + repository(owner: $org, name: $repo) { + collaborators(query: $user, first: 1) { + totalCount + } + } + } ' -f org=${{ github.repository_owner }} -f repo=${{ github.event.repository.name }} -f user=${{ github.actor }} > collaborators.json + + echo 'IS_COLLABORATOR='$(jq -r '.data.repository.collaborators.totalCount' collaborators.json) >> $GITHUB_ENV + - uses: actions/add-to-project@v0.4.0 + # only add issues/prs from outside contributors to the project + if: ${{ env.IS_COLLABORATOR == 0 }} with: - project-url: https://github.com/orgs/cypress-io/projects/9 + project-url: https://github.com/orgs/${{github.repository_owner}}/projects/${{env.PROJECT_NUMBER}} github-token: ${{ secrets.ADD_TO_PROJECT_TOKEN }} -