Skip to content

Commit 45097aa

Browse files
badal773Badal Kumar Prusty
and
Badal Kumar Prusty
authored
misc: adding validation for public repo (#6137)
* adding validation for public repo * removed the statuscode check * debug-1 * debug-2 * debug-3 * debug-4 * debug-5 * debug-6 --------- Co-authored-by: Badal Kumar Prusty <badalkumar@Badals-MacBook-Pro.local>
1 parent 8866cbe commit 45097aa

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

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

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,19 +101,36 @@ jobs:
101101
# Form the issue API URL dynamically
102102
issue_api_url="https://api.github.com/repos/$repo/issues/$issue_num"
103103
echo "API URL: $issue_api_url"
104-
105-
# Check if the issue exists in the private repo
106-
response_code=$(curl -s -o /dev/null -w "%{http_code}" \
104+
105+
if [[ $repo == "devtron-labs/devtron" || $repo == "devtron-labs/devtron-services" || $repo == "devtron-labs/dashboard" ]]; then
106+
echo "No extra arguments needed: public repository detected."
107+
response_code=$(curl -s -o /dev/null -w "%{http_code}" \
108+
"$issue_api_url")
109+
110+
else
111+
echo "Adding extra arguments for authentication: private repository detected."
112+
response_code=$(curl -s -o /dev/null -w "%{http_code}" \
107113
--header "authorization: Bearer ${{ secrets.GH_PR_VALIDATOR_TOKEN }}" \
108114
"$issue_api_url")
109-
115+
fi
116+
117+
echo "Response Code: $response_code"
110118
if [[ "$response_code" -eq 200 ]]; then
111119
echo "Issue #$issue_num is valid and exists in $repo."
112120

113121
# Fetch the current state of the issue (open/closed) from the private repository.
114-
issue_status=$(curl -s \
122+
if [[ $repo == "devtron-labs/devtron" || $repo == "devtron-labs/devtron-services" || $repo == "devtron-labs/dashboard" ]]; then
123+
echo "No extra arguments needed: public repository detected."
124+
issue_status=$(curl -s \
125+
"$issue_api_url"| jq '.state'|tr -d \")
126+
else
127+
echo "Adding extra arguments for authentication: private repository detected."
128+
issue_status=$(curl -s \
115129
--header "authorization: Bearer ${{ secrets.GH_PR_VALIDATOR_TOKEN }}" \
116-
"$issue_api_url" | jq '.state'|tr -d \")
130+
"$issue_api_url"| jq '.state'|tr -d \")
131+
fi
132+
echo "Issue Status: $issue_status"
133+
117134
# Check if the issue is still open.
118135
if [[ "$issue_status" == open ]]; then
119136
echo "Issue #$issue_num is opened."

0 commit comments

Comments
 (0)