Skip to content

Repo sync for protected branch #2

Repo sync for protected branch

Repo sync for protected branch #2

name: Bypass Code Owner Approval
on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
bypass_approval:
runs-on: ubuntu-latest
steps:
- name: Check if PR author is a code owner
id: check-author
run: |
TEAM_MEMBERS=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/orgs/MicrosoftDocs/teams/kusto-doc-writers/members)
if echo "$TEAM_MEMBERS" | grep -q "\"login\": \"${{ github.actor }}\""; then
DEBUG_IS_CODEOWNER=true
echo "is_codeowner=true" >> $GITHUB_ENV
else
DEBUG_IS_CODEOWNER=false
echo "is_codeowner=false" >> $GITHUB_ENV
fi
echo "::debug::Team members -- $TEAM_MEMBERS"
echo "::debug::is_codeowner -- $DEBUG_IS_CODEOWNER"
- name: Bypass approval if author is a code owner
id: bypass-approval
if: steps.check-author.outputs.is_codeowner == 'true'
run: |
echo "Bypassing approval for code owner"
curl -s -X POST -H "Authorization: token ${{ secrets.GITHUB_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"}'