mirror of
https://github.com/gnif/LookingGlass.git
synced 2025-04-25 08:06:30 +00:00
[github] pr-check: Automatically add review requesting changes when PR author is not found in AUTHORS
This commit is contained in:
parent
03ca20d3e4
commit
fbb489b9b6
22
.github/workflows/pr-check.yml
vendored
22
.github/workflows/pr-check.yml
vendored
@ -3,16 +3,36 @@ on: pull_request
|
|||||||
jobs:
|
jobs:
|
||||||
authors:
|
authors:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
pull-requests: write
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v1
|
||||||
- name: Check AUTHORS file
|
- name: Check AUTHORS file
|
||||||
|
id: check-authors
|
||||||
run: |
|
run: |
|
||||||
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)"
|
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)"
|
||||||
|
echo "user=$user" >> "$GITHUB_OUTPUT"
|
||||||
echo "Checking if GitHub user $user is in AUTHORS file..."
|
echo "Checking if GitHub user $user is in AUTHORS file..."
|
||||||
if grep -q -E '> \('"$user"'\)' AUTHORS; then
|
if grep -q -E '> \('"$user"'\)' AUTHORS; then
|
||||||
echo "$user found in AUTHORS file, all good!"
|
echo "$user found in AUTHORS file, all good!"
|
||||||
else
|
else
|
||||||
echo "$user not found in AUTHORS file."
|
echo "$user not found in AUTHORS file."
|
||||||
echo "Please add yourself to the AUTHORS file and try again."
|
echo "Please add yourself to the AUTHORS file and try again."
|
||||||
exit 1
|
echo "not-found=yes" >> "$GITHUB_OUTPUT"
|
||||||
fi
|
fi
|
||||||
|
- name: 'Not found: Create review requesting changes'
|
||||||
|
if: ${{ steps.check-authors.outputs.not-found }}
|
||||||
|
uses: actions/github-script@v7
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
github.rest.pulls.createReview({
|
||||||
|
owner: context.issue.owner,
|
||||||
|
repo: context.issue.repo,
|
||||||
|
pull_number: context.issue.number,
|
||||||
|
event: "REQUEST_CHANGES",
|
||||||
|
body: "@${{ steps.check-authors.outputs.user }} not found in AUTHORS file.\n" +
|
||||||
|
"Please add yourself to the AUTHORS file and try again."
|
||||||
|
});
|
||||||
|
- name: 'Not found: Fail job'
|
||||||
|
if: ${{ steps.check-authors.outputs.not-found }}
|
||||||
|
run: exit 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user