Skip to content

Commit

Permalink
misc: adding validation for public repo (#6137)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
badal773 and Badal Kumar Prusty authored Nov 28, 2024
1 parent 8866cbe commit 45097aa
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions .github/workflows/pr-issue-validator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,19 +101,36 @@ jobs:
# Form the issue API URL dynamically
issue_api_url="https://api.github.com/repos/$repo/issues/$issue_num"
echo "API URL: $issue_api_url"

# Check if the issue exists in the private repo
response_code=$(curl -s -o /dev/null -w "%{http_code}" \

if [[ $repo == "devtron-labs/devtron" || $repo == "devtron-labs/devtron-services" || $repo == "devtron-labs/dashboard" ]]; then
echo "No extra arguments needed: public repository detected."
response_code=$(curl -s -o /dev/null -w "%{http_code}" \
"$issue_api_url")

else
echo "Adding extra arguments for authentication: private repository detected."
response_code=$(curl -s -o /dev/null -w "%{http_code}" \
--header "authorization: Bearer ${{ secrets.GH_PR_VALIDATOR_TOKEN }}" \
"$issue_api_url")

fi

echo "Response Code: $response_code"
if [[ "$response_code" -eq 200 ]]; then
echo "Issue #$issue_num is valid and exists in $repo."

# Fetch the current state of the issue (open/closed) from the private repository.
issue_status=$(curl -s \
if [[ $repo == "devtron-labs/devtron" || $repo == "devtron-labs/devtron-services" || $repo == "devtron-labs/dashboard" ]]; then
echo "No extra arguments needed: public repository detected."
issue_status=$(curl -s \
"$issue_api_url"| jq '.state'|tr -d \")
else
echo "Adding extra arguments for authentication: private repository detected."
issue_status=$(curl -s \
--header "authorization: Bearer ${{ secrets.GH_PR_VALIDATOR_TOKEN }}" \
"$issue_api_url" | jq '.state'|tr -d \")
"$issue_api_url"| jq '.state'|tr -d \")
fi
echo "Issue Status: $issue_status"

# Check if the issue is still open.
if [[ "$issue_status" == open ]]; then
echo "Issue #$issue_num is opened."
Expand Down

0 comments on commit 45097aa

Please sign in to comment.