|
19 | 19 | #gt-placeholder-permissions-start |
20 | 20 | permissions: |
21 | 21 | contents: read |
| 22 | + pull-requests: write |
22 | 23 | #gt-placeholder-permissions-end |
23 | 24 |
|
24 | 25 | jobs: |
|
42 | 43 | run: | |
43 | 44 | user="${{ github.actor }}" |
44 | 45 | repo="${{ github.repository }}" |
45 | | - status=$(curl -s -o /dev/null -w '%{http_code}' \ |
46 | | - -H "Authorization: Bearer $GITHUB_TOKEN" \ |
| 46 | + status=$(curl -L -s -o /dev/null -w '%{http_code}' \ |
| 47 | + -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ |
47 | 48 | -H "Accept: application/vnd.github+json" \ |
48 | 49 | "https://api.github.com/repos/$repo/collaborators/$user") |
49 | 50 | echo "status $status for user $user" |
|
52 | 53 | else |
53 | 54 | echo "reviewer=" >> $GITHUB_OUTPUT |
54 | 55 | fi |
55 | | - env: |
56 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
57 | 56 |
|
58 | 57 | - name: Create Pull Request if necessary |
| 58 | + id: create-pr |
59 | 59 | uses: peter-evans/create-pull-request@v7 |
60 | 60 | with: |
61 | 61 | branch: auto-cleanup |
|
65 | 65 | delete-branch: true |
66 | 66 | token: ${{ secrets.AUTO_PR_TOKEN }} |
67 | 67 | push-to-fork: ${{ vars.AUTO_PR_FORK_NAME != '' && vars.AUTO_PR_FORK_NAME || secrets.AUTO_PR_FORK_NAME }} |
68 | | - reviewers: ${{ steps.check-collaborator.outputs.reviewer }} |
| 68 | + |
| 69 | + - name: set reviewer |
| 70 | + if: ${{ steps.check-collaborator.outputs.reviewer != '' && steps.check-collaborator.outputs.reviewer != null && steps.create-pr.outputs.pull-request-operation == 'created' }} |
| 71 | + run: | |
| 72 | + repo="${{ github.repository }}" |
| 73 | + curl -L \ |
| 74 | + -X POST \ |
| 75 | + -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ |
| 76 | + -H "Accept: application/vnd.github+json" \ |
| 77 | + -H "X-GitHub-Api-Version: 2022-11-28" \ |
| 78 | + https://api.github.com/repos/$repo/pulls/${{steps.create-pr.outputs.pull-request-number}}/requested_reviewers \ |
| 79 | + -d '{"reviewers":["${{ steps.check-collaborator.outputs.reviewer }}"]}' |
0 commit comments