Skip to content

update: added a step on the github actions to check for multiple open prs #494

update: added a step on the github actions to check for multiple open prs

update: added a step on the github actions to check for multiple open prs #494

Workflow file for this run

name: Content Compliance Check
on: [pull_request]
permissions:
pull-requests: write
contents: read
jobs:
content-compliance:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- 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 BASE repository
open_prs=$(gh pr list --repo $GITHUB_REPOSITORY --state open --json number,author,headRefName)
echo "All open PRs: $open_prs"
# Filter PRs by author
contributor_prs=$(echo "$open_prs" | jq -c --arg login "$contributor_login" '.[] | select(.author.login == $login)')
echo "Contributor's PRs: $contributor_prs"
pr_count=$(echo "$contributor_prs" | jq -s '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 Compliance
run: |
# ... (keep existing file validation logic) ...
- name: Markdown Lint
run: npx markdownlint '**/*.md' --ignore node_modules