Repo sync for protected branch #2
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"}' |