Skip to content

Commit

Permalink
Merge pull request #2358 from MicrosoftDocs/main638587331910201486syn…
Browse files Browse the repository at this point in the history
…c_temp

For protected branch, push strategy should use PR and merge to target branch method to work around git push error
  • Loading branch information
learn-build-service-prod[bot] authored Aug 8, 2024
2 parents c21115a + c8e12f8 commit b1feba4
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/bypass-codeowner-approval.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Bypass Code Owner Approval
on:
pull_request:
types: [opened, synchronize, reopened]

jobs:
bypass_approval:
runs-on: ubuntu-latest
env:
ACTION_TOKEN_SS: ${{ secrets.ACTIONTOKEN }}
ACTION_TOKEN_YS: ${{ secrets.ACTIONTOKEN_YS }}
steps:
- name: Approve PR if author is a code owner
id: check-author
run: |
echo "Check if PR author is a code owner"
TEAM_MEMBERS=$(curl -s -H "Authorization: token $ACTION_TOKEN_SS" \
https://api.github.com/orgs/MicrosoftDocs/teams/kusto-doc-writers/members)
echo "Checking if login in team -- ${{ github.actor }}"
IS_CODEOWNER=false
if echo "$TEAM_MEMBERS" | grep -q "\"login\": \"${{ github.actor }}\""; then
echo "Login Found"
IS_CODEOWNER=true
fi
echo "is_codeowner -- $IS_CODEOWNER"
if $IS_CODEOWNER; then
echo "Bypassing approval for code owner"
if [ "${{ github.actor }}" == "shsagir" ]; then
ACTION_TOKEN=$ACTION_TOKEN_YS
else
ACTION_TOKEN=$ACTION_TOKEN_SS
fi
curl -s -X POST -H "Authorization: token $ACTION_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"}'
fi

0 comments on commit b1feba4

Please sign in to comment.