Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: auto approve PRs with non-critical changes from members of kosli-dev #39

Merged
merged 1 commit into from
Nov 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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]
Loading