Skip to content

Commit

Permalink
added pr policy rules
Browse files Browse the repository at this point in the history
Signed-off-by: mojafa <[email protected]>
  • Loading branch information
mojafa committed Jan 31, 2025
1 parent 19c7219 commit cc7ea93
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/content-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,44 @@ jobs:

- name: Install dependencies
run: npm install

- name: Check for existing open PRs
id: check-prs
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
contributor_login=$(jq -r '.pull_request.user.login' "$GITHUB_EVENT_PATH")
pr_branch=$(jq -r '.pull_request.head.ref' "$GITHUB_EVENT_PATH")
# Fetch open PRs from the repository
open_prs=$(gh pr list --repo $GITHUB_REPOSITORY --state open --json author,headRefName)
echo "All open PRs: $open_prs"
# Filter PRs by author and convert to array
contributor_prs=$(echo "$open_prs" | jq --arg login "$contributor_login" '[.[] | select(.author.login == $login)]')
echo "Filtered PRs: $contributor_prs"
pr_count=$(echo "$contributor_prs" | jq 'length')
echo "PR count: $pr_count"
if [ "$pr_count" -gt 1 ]; then
echo "has_open_prs=true" >> "$GITHUB_OUTPUT"
elif [ "$pr_count" -eq 1 ]; then
existing_branch=$(echo "$contributor_prs" | jq -r '.[0].headRefName')
if [ "$existing_branch" != "$pr_branch" ]; then
echo "has_open_prs=true" >> "$GITHUB_OUTPUT"
else
echo "has_open_prs=false" >> "$GITHUB_OUTPUT"
fi
else
echo "has_open_prs=false" >> "$GITHUB_OUTPUT"
fi

- name: Fail if multiple PRs
if: steps.check-prs.outputs.has_open_prs == 'true'
run: |
echo "::error::Our policy allows only one active PR per contributor. Please complete existing work before submitting new changes."
exit 1
- name: File Naming and Folder Structure Compliance
run: |
Expand Down

0 comments on commit cc7ea93

Please sign in to comment.