Skip to content

Commit

Permalink
Add automatic approval action
Browse files Browse the repository at this point in the history
  • Loading branch information
sanmai committed Feb 17, 2024
1 parent 4f05915 commit c7a995a
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/autoapprove.yaml
@@ -0,0 +1,39 @@
name: Your Workflow Name

on:
pull_request:
types:
- opened
- synchronize

jobs:
your_job_name:
runs-on: ubuntu-latest

steps:
- name: Check PR author
run: |
PR_AUTHOR=$(curl -sSL https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }} | jq -r '.user.login')

Check failure on line 16 in .github/workflows/autoapprove.yaml

View workflow job for this annotation

GitHub Actions / Static Analysis and Validation

16:81 [line-length] line too long (154 > 80 characters)
if [[ "${{ github.actor }}" == "${PR_AUTHOR}" ]]; then
echo "PR author is the owner of the repository."
# Your steps for the case where the author is the owner
# Approve the pull request using GitHub API
TOKEN=${{ secrets.GITHUB_TOKEN }}
API_URL="https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/reviews"

Check failure on line 24 in .github/workflows/autoapprove.yaml

View workflow job for this annotation

GitHub Actions / Static Analysis and Validation

24:81 [line-length] line too long (129 > 80 characters)
APPROVAL_RESPONSE=$(curl -X POST -H "Authorization: Bearer ${TOKEN}" -H "Accept: application/vnd.github.v3+json" -d '{"event": "APPROVE"}' ${API_URL})

Check failure on line 26 in .github/workflows/autoapprove.yaml

View workflow job for this annotation

GitHub Actions / Static Analysis and Validation

26:81 [line-length] line too long (162 > 80 characters)
APPROVAL_STATUS=$(echo ${APPROVAL_RESPONSE} | jq -r '.state')
if [[ "${APPROVAL_STATUS}" == "APPROVED" ]]; then
echo "Pull request approved."
else
echo "Failed to approve pull request. Check workflow logs for details."

Check failure on line 32 in .github/workflows/autoapprove.yaml

View workflow job for this annotation

GitHub Actions / Static Analysis and Validation

32:81 [line-length] line too long (85 > 80 characters)
exit 1
fi
else
echo "PR author is not the owner of the repository. Skipping this step."

Check failure on line 37 in .github/workflows/autoapprove.yaml

View workflow job for this annotation

GitHub Actions / Static Analysis and Validation

37:81 [line-length] line too long (84 > 80 characters)
# Your steps for the case where the author is not the owner
fi

0 comments on commit c7a995a

Please sign in to comment.