Skip to content

Commit 632f20c

Browse files
badal773Badal Kumar Prusty
and
Badal Kumar Prusty
authored
misc: adding pr validator for fork prs as gh command will not work (#6143)
* added support for forked-repo as gh-command not work * adding extra permissions to get projects --------- Co-authored-by: Badal Kumar Prusty <[email protected]>
1 parent d37649f commit 632f20c

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

.github/CODEOWNERS

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ scripts/sql @prakarsh-dt @vikramdevtron @nishant-d @vivek-devtron
1111
scripts/utilities @prakarsh-dt @nishant-d @pawan-mehta-dt @vivek-devtron
1212

1313
#Github Specific
14-
.github/ @prakarsh-dt @nishant-d @pawan-mehta-dt @vikramdevtron
14+
.github/ @prakarsh-dt @nishant-d @pawan-mehta-dt @vikramdevtron @tayalrishabh96

.github/workflows/pr-issue-validator.yaml

+19
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ jobs:
2626
issues: write
2727
contents: read
2828
pull-requests: write
29+
repository-projects: read
2930
steps:
3031
- name: Checkout repository
3132
uses: actions/checkout@v2
@@ -40,6 +41,16 @@ jobs:
4041
PRNUM: ${{ github.event.pull_request.number }}
4142
TITLE: ${{ github.event.pull_request.title }}
4243
run: |
44+
45+
echo "base or target repo : ${{ github.event.pull_request.base.repo.full_name }}"
46+
echo "head or source repo : ${{ github.event.pull_request.head.repo.full_name }}"
47+
48+
if [[ ${{ github.event.pull_request.head.repo.full_name }} == ${{ github.event.pull_request.base.repo.full_name }} ]]; then
49+
export forked=false
50+
else
51+
export forked=true
52+
fi
53+
4354
set -x
4455
# Skip validation for documentation or chore PRs
4556
if [[ "$TITLE" =~ ^(doc:|docs:|chore:|misc:) ]]; then
@@ -134,11 +145,19 @@ jobs:
134145
# Check if the issue is still open.
135146
if [[ "$issue_status" == open ]]; then
136147
echo "Issue #$issue_num is opened."
148+
if [[ $forked == true ]]; then
149+
echo "PR:Ready-to-Review, exiting gracefully"
150+
exit 0
151+
fi
137152
# Remove the 'Issue-verification-failed' label (if present) and add 'Ready-to-Review'.
138153
gh pr edit $PRNUM --remove-label "PR:Issue-verification-failed"
139154
gh pr edit $PRNUM --add-label "PR:Ready-to-Review"
140155
else
141156
echo "Issue #$issue_num is closed. Please link an open issue to proceed."
157+
if [[ $forked == true ]]; then
158+
echo "PR:Ready-to-Review, exiting gracefully"
159+
exit 0
160+
fi
142161
# Add a comment to the PR indicating the issue is not linked correctly.
143162
gh pr comment $PRNUM --body "PR is linked to a closed issue. Please link an open issue to proceed."
144163

0 commit comments

Comments
 (0)