Skip to content

Commit 543020d

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

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

.github/workflows/cleanup.yml

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ on:
1919
#gt-placeholder-permissions-start
2020
permissions:
2121
contents: read
22+
pull-requests: write
2223
#gt-placeholder-permissions-end
2324

2425
jobs:
@@ -42,20 +43,20 @@ jobs:
4243
run: |
4344
user="${{ github.actor }}"
4445
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 }}" \
4748
-H "Accept: application/vnd.github+json" \
48-
"https://api.github.com/repos/$repo/collaborators/$user")
49+
"https://api.github.com/repos/$repo/collaborators/$user"
50+
)
4951
echo "status $status for user $user"
5052
if [ "$status" = "204" ]; then
5153
echo "reviewer=$user" >> $GITHUB_OUTPUT
5254
else
5355
echo "reviewer=" >> $GITHUB_OUTPUT
5456
fi
55-
env:
56-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5757
5858
- name: Create Pull Request if necessary
59+
id: create-pr
5960
uses: peter-evans/create-pull-request@v7
6061
with:
6162
branch: auto-cleanup
@@ -65,4 +66,18 @@ jobs:
6566
delete-branch: true
6667
token: ${{ secrets.AUTO_PR_TOKEN }}
6768
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 }}
69+
70+
- name: set reviewer
71+
if: ${{ steps.check-collaborator.outputs.reviewer != '' && steps.check-collaborator.outputs.reviewer != null && steps.create-pr.outputs.pull-request-operation == 'created' }}
72+
run: |
73+
repo="${{ github.repository }}"
74+
status=$(curl -L -s -o /dev/null -w '%{http_code}' \
75+
-X POST \
76+
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
77+
-H "Accept: application/vnd.github+json" \
78+
-H "X-GitHub-Api-Version: 2022-11-28" \
79+
https://api.github.com/repos/$repo/pulls/${{steps.create-pr.outputs.pull-request-number}}/requested_reviewers \
80+
-d '{"reviewers":["${{ steps.check-collaborator.outputs.reviewer }}"]}'
81+
)
82+
echo "status $status"
83+
[ "$status" = "201" ]

0 commit comments

Comments
 (0)