Skip to content

Commit 04e0835

Browse files
committed
looks like setting reviewer via peter-evans doesn't work
1 parent 658d254 commit 04e0835

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

.github/workflows/cleanup.yml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ jobs:
4242
run: |
4343
user="${{ github.actor }}"
4444
repo="${{ github.repository }}"
45-
status=$(curl -s -o /dev/null -w '%{http_code}' \
46-
-H "Authorization: Bearer $GITHUB_TOKEN" \
45+
status=$(curl -L -s -o /dev/null -w '%{http_code}' \
46+
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
4747
-H "Accept: application/vnd.github+json" \
4848
"https://api.github.com/repos/$repo/collaborators/$user")
4949
echo "status $status for user $user"
@@ -52,10 +52,9 @@ jobs:
5252
else
5353
echo "reviewer=" >> $GITHUB_OUTPUT
5454
fi
55-
env:
56-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5755
5856
- name: Create Pull Request if necessary
57+
id: create-pr
5958
uses: peter-evans/create-pull-request@v7
6059
with:
6160
branch: auto-cleanup
@@ -65,4 +64,15 @@ jobs:
6564
delete-branch: true
6665
token: ${{ secrets.AUTO_PR_TOKEN }}
6766
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 }}
67+
68+
- name: set reviewer
69+
if: ${{ steps.check-collaborator.outputs.reviewer != '' && steps.check-collaborator.outputs.reviewer != null && steps.create-pr.outputs.pull-request-operation == 'created' }}
70+
run: |
71+
repo="${{ github.repository }}"
72+
curl -L \
73+
-X POST \
74+
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
75+
-H "Accept: application/vnd.github+json" \
76+
-H "X-GitHub-Api-Version: 2022-11-28" \
77+
https://api.github.com/repos/$repo/pulls/${{steps.create-pr.outputs.pull-request-number}}/requested_reviewers \
78+
-d '{"reviewers":["${{ steps.check-collaborator.outputs.reviewer }}"]}'

0 commit comments

Comments
 (0)