Skip to content

Commit

Permalink
CI: auto approve PRs with non-critical changes from members of kosli-…
Browse files Browse the repository at this point in the history
…dev (#39)
  • Loading branch information
arstanaly authored Nov 10, 2023
1 parent 9991717 commit e66042e
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/auto-approve.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Auto approve
on:
pull_request_target:
types:
- opened
branches:
- main

jobs:
auto-approve:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: write

steps:
- name: check requester
run: |
# fail job if the requester is not a member of the organization
is_member=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/orgs/kosli-dev/members \
| jq -r ".[].login" \
| grep -w "${{ github.event.pull_request.user.login }}")
if [[ ! is_member ]]; then
echo "User ${{ github.event.pull_request.user.login }} is not a member of the organization"
exit 1
fi
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v40

- name: Check non critical
run: |
ACCEPTED_PATHS="^bin/|^design-docs/"
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
echo "$file"
# exit as soon as a file does not match the ACCEPTED_PATHS
[[ "$file" =~ ${ACCEPTED_PATHS} ]] || exit 1
done
- name: Approve pull request
uses: hmarr/auto-approve-action@v3
with:
review-message: "Auto approved since only non critical files were changed"


- name: Merge to master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MERGE_LABELS: ""
MERGE_METHOD: squash
MERGE_ERROR_FAIL: true
uses: pascalgn/[email protected]

0 comments on commit e66042e

Please sign in to comment.