@@ -3,16 +3,36 @@ on: pull_request
33jobs :
44 authors :
55 runs-on : ubuntu-latest
6+ permissions :
7+ pull-requests : write
68 steps :
79 - uses : actions/checkout@v1
810 - name : Check AUTHORS file
11+ id : check-authors
912 run : |
1013 user="$(curl -H 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' -s https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }} | jq -r .user.login)"
14+ echo "user=$user" >> "$GITHUB_OUTPUT"
1115 echo "Checking if GitHub user $user is in AUTHORS file..."
1216 if grep -q -E '> \('"$user"'\)' AUTHORS; then
1317 echo "$user found in AUTHORS file, all good!"
1418 else
1519 echo "$user not found in AUTHORS file."
1620 echo "Please add yourself to the AUTHORS file and try again."
17- exit 1
21+ echo "not-found=yes" >> "$GITHUB_OUTPUT"
1822 fi
23+ - name : ' Not found: Create review requesting changes'
24+ if : ${{ steps.check-authors.outputs.not-found }}
25+ uses : actions/github-script@v7
26+ with :
27+ script : |
28+ github.rest.pulls.createReview({
29+ owner: context.issue.owner,
30+ repo: context.issue.repo,
31+ pull_number: context.issue.number,
32+ event: "REQUEST_CHANGES",
33+ body: "@${{ steps.check-authors.outputs.user }} not found in AUTHORS file.\n" +
34+ "Please add yourself to the AUTHORS file and try again."
35+ });
36+ - name : ' Not found: Fail job'
37+ if : ${{ steps.check-authors.outputs.not-found }}
38+ run : exit 1
0 commit comments