Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

misc: adding pr validator for fork prs as gh command will not work #6143

Merged
merged 11 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ scripts/sql @prakarsh-dt @vikramdevtron @nishant-d @vivek-devtron
scripts/utilities @prakarsh-dt @nishant-d @pawan-mehta-dt @vivek-devtron

#Github Specific
.github/ @prakarsh-dt @nishant-d @pawan-mehta-dt @vikramdevtron
.github/ @prakarsh-dt @nishant-d @pawan-mehta-dt @vikramdevtron @tayalrishabh96
19 changes: 19 additions & 0 deletions .github/workflows/pr-issue-validator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
issues: write
contents: read
pull-requests: write
repository-projects: read
steps:
- name: Checkout repository
uses: actions/checkout@v2
Expand All @@ -40,6 +41,16 @@ jobs:
PRNUM: ${{ github.event.pull_request.number }}
TITLE: ${{ github.event.pull_request.title }}
run: |

echo "base or target repo : ${{ github.event.pull_request.base.repo.full_name }}"
echo "head or source repo : ${{ github.event.pull_request.head.repo.full_name }}"

if [[ ${{ github.event.pull_request.head.repo.full_name }} == ${{ github.event.pull_request.base.repo.full_name }} ]]; then
export forked=false
else
export forked=true
fi

set -x
# Skip validation for documentation or chore PRs
if [[ "$TITLE" =~ ^(doc:|docs:|chore:|misc:) ]]; then
Expand Down Expand Up @@ -134,11 +145,19 @@ jobs:
# Check if the issue is still open.
if [[ "$issue_status" == open ]]; then
echo "Issue #$issue_num is opened."
if [[ $forked == true ]]; then
echo "PR:Ready-to-Review, exiting gracefully"
exit 0
fi
# Remove the 'Issue-verification-failed' label (if present) and add 'Ready-to-Review'.
gh pr edit $PRNUM --remove-label "PR:Issue-verification-failed"
gh pr edit $PRNUM --add-label "PR:Ready-to-Review"
else
echo "Issue #$issue_num is closed. Please link an open issue to proceed."
if [[ $forked == true ]]; then
echo "PR:Ready-to-Review, exiting gracefully"
exit 0
fi
# Add a comment to the PR indicating the issue is not linked correctly.
gh pr comment $PRNUM --body "PR is linked to a closed issue. Please link an open issue to proceed."

Expand Down