feat: ownership transfer script can set arbitrary manager #449
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: Enforce Review Rules | |
on: | |
pull_request: | |
types: [opened, edited, synchronize] | |
jobs: | |
enforce-review-rules: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Check if PR modifies specific path | |
shell: bash | |
id: check-path | |
run: | | |
BASE_SHA=$(jq -r .pull_request.base.sha < $GITHUB_EVENT_PATH) | |
HEAD_SHA=$(jq -r .pull_request.head.sha < $GITHUB_EVENT_PATH) | |
git fetch origin $BASE_SHA $HEAD_SHA | |
files=$(git diff --name-only $BASE_SHA $HEAD_SHA | tr '\n' ' ') | |
echo "files=$files" >> $GITHUB_OUTPUT | |
if echo "$files" | grep -q 'src/contracts/'; then | |
echo "specific_path=true" >> $GITHUB_OUTPUT | |
else | |
echo "specific_path=false" >> $GITHUB_OUTPUT | |
fi | |
- name: Ensure required reviewers | |
shell: bash | |
id: ensure-reviewers | |
run: | | |
GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} | |
PR_NUMBER=${{ github.event.pull_request.number }} | |
REPO=${{ github.repository }} | |
# Fetch approved and non-dismissed reviews of the PR | |
REVIEWERS=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \ | |
"https://api.github.com/repos/$REPO/pulls/$PR_NUMBER/reviews" \ | |
| jq -r '[.[] | select(.state == "APPROVED" and .dismissed_at == null) | .user.login] | unique | .[]') | |
if [ $? -ne 0 ]; then | |
echo "Failed to fetch reviews" | |
exit 1 | |
fi | |
NUM_REVIEWERS=$(echo "$REVIEWERS" | wc -w) | |
# Check review requirements | |
if [ "${{ steps.check-path.outputs.specific_path }}" == "true" ]; then | |
if [ "$NUM_REVIEWERS" -lt 2 ]; then | |
echo "Insufficient reviewers for src/contracts/ path. Required: 2 reviewers." | |
echo "review_check_passed=false" >> $GITHUB_OUTPUT | |
exit 1 | |
fi | |
fi | |
echo "review_check_passed=true" >> $GITHUB_OUTPUT | |
- name: Success message | |
if: steps.ensure-reviewers.outputs.review_check_passed == 'true' | |
run: echo "Review checks passed successfully!" |