Skip to content

Commit

Permalink
Update auto_approve.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
RawFish69 authored Dec 8, 2023
1 parent c4f58ad commit 09a7b48
Showing 1 changed file with 30 additions and 28 deletions.
58 changes: 30 additions & 28 deletions .github/workflows/auto_approve.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,35 @@ jobs:
auto-approve-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
ref: main
- name: Checkout repository
uses: actions/checkout@v2
with:
ref: main


- name: Check username
id: check_user
run: |
AUTHOR="${{ github.event.pull_request.user.login }}"
ALLOWED_USERS="EternityTQ, Cre-epbee, tankofpacer"
echo "ALLOWED=false" >> $GITHUB_ENV
if [[ $ALLOWED_USERS =~ (^|[[:space:]])$AUTHOR($|[[:space:]]) ]]; then
echo "ALLOWED=true" >> $GITHUB_ENV
fi

- name: Check username
id: check_user
run: |
AUTHOR="${{ github.event.pull_request.user.login }}"
ALLOWED_USERS="EternityTQ, Cre-epbee, tankofpacer"
echo "ALLOWED=false" >> $GITHUB_ENV
if [[ $ALLOWED_USERS =~ (^|[[:space:]])$AUTHOR($|[[:space:]]) ]]; then
echo "ALLOWED=true" >> $GITHUB_ENV
fi
- name: Auto approve pull request
if: env.ALLOWED == 'true'
run: |
curl -X POST -H "Authorization: token ${{ secrets.NORI_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/reviews \
-d '{"event":"APPROVE"}'
- name: Auto approve pull request
if: env.ALLOWED == 'true'
run: |
curl -X POST -H "Authorization: token ${{ secrets.NORI_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/reviews \
-d '{"event":"APPROVE"}' -S -s --fail || echo "Failed to approve pull request"
- name: Merge pull request
if: env.ALLOWED == 'true'
run: |
curl -X PUT -H "Authorization: token ${{ secrets.NORI_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/merge \
-d '{"merge_method":"squash"}' -S -s --fail || echo "Failed to merge pull request"
- name: Merge pull request
if: env.ALLOWED == 'true'
run: |
curl -X PUT -H "Authorization: token ${{ secrets.NORI_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/merge \
-d '{"commit_title":"Automatically merged by GitHub Actions","commit_message":"Merging approved changes","merge_method":"merge"}'

0 comments on commit 09a7b48

Please sign in to comment.