From 52ebcb185ed5b2eb9020e4c6ac1c3a9d1693caea Mon Sep 17 00:00:00 2001 From: Badal Kumar Prusty Date: Thu, 28 Nov 2024 15:45:12 +0530 Subject: [PATCH 1/8] adding validation for public repo --- .github/workflows/pr-issue-validator.yaml | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/.github/workflows/pr-issue-validator.yaml b/.github/workflows/pr-issue-validator.yaml index b20e4af27d..2cf92ecec6 100644 --- a/.github/workflows/pr-issue-validator.yaml +++ b/.github/workflows/pr-issue-validator.yaml @@ -101,19 +101,26 @@ 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" - + + extra_args_for_auth="" + if [[ $repo == "devtron-labs/devtron" || $repo == "devtron-labs/devtron-services" || $repo == "devtron-labs/dashboard" ]]; then + echo "No extra arguments needed: public repository detected." + extra_args_for_auth="" + else + echo "Adding extra arguments for authentication: private repository detected." + extra_args_for_auth='--header "Authorization: Bearer ${{ secrets.GH_PR_VALIDATOR_TOKEN }}"' + fi + # Check if the issue exists in the private repo - response_code=$(curl -s -o /dev/null -w "%{http_code}" \ - --header "authorization: Bearer ${{ secrets.GH_PR_VALIDATOR_TOKEN }}" \ - "$issue_api_url") - + response_code=$(curl -s -o /dev/null -w "%{http_code}" $extra_args_for_auth "$issue_api_url") + + + 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 \ - --header "authorization: Bearer ${{ secrets.GH_PR_VALIDATOR_TOKEN }}" \ - "$issue_api_url" | jq '.state'|tr -d \") + issue_status=$(curl -s -o /dev/null -w "%{http_code}" $extra_args_for_auth "$issue_api_url" | jq '.state'|tr -d \") # Check if the issue is still open. if [[ "$issue_status" == open ]]; then echo "Issue #$issue_num is opened." From a36073b61587c5746081ec1b32d312a1b7c58519 Mon Sep 17 00:00:00 2001 From: Badal Kumar Prusty Date: Thu, 28 Nov 2024 15:46:59 +0530 Subject: [PATCH 2/8] removed the statuscode check --- .github/workflows/pr-issue-validator.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-issue-validator.yaml b/.github/workflows/pr-issue-validator.yaml index 2cf92ecec6..13f8c7df18 100644 --- a/.github/workflows/pr-issue-validator.yaml +++ b/.github/workflows/pr-issue-validator.yaml @@ -120,7 +120,7 @@ jobs: 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 -o /dev/null -w "%{http_code}" $extra_args_for_auth "$issue_api_url" | jq '.state'|tr -d \") + issue_status=$(curl -s $extra_args_for_auth "$issue_api_url" | jq '.state'|tr -d \") # Check if the issue is still open. if [[ "$issue_status" == open ]]; then echo "Issue #$issue_num is opened." From 9e142ddeaed5c651eb111af69eba70caccb97ce0 Mon Sep 17 00:00:00 2001 From: Badal Kumar Prusty Date: Thu, 28 Nov 2024 16:17:40 +0530 Subject: [PATCH 3/8] debug-1 --- .github/workflows/pr-issue-validator.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/pr-issue-validator.yaml b/.github/workflows/pr-issue-validator.yaml index 13f8c7df18..4a3c0a7c57 100644 --- a/.github/workflows/pr-issue-validator.yaml +++ b/.github/workflows/pr-issue-validator.yaml @@ -114,7 +114,9 @@ jobs: # Check if the issue exists in the private repo response_code=$(curl -s -o /dev/null -w "%{http_code}" $extra_args_for_auth "$issue_api_url") + echo "Checking extra arguments for authentication: $extra_args_for_auth" + echo "Response Code: $response_code" if [[ "$response_code" -eq 200 ]]; then echo "Issue #$issue_num is valid and exists in $repo." From c99152436b815eb7f3ddf2bd4aa70355925bc639 Mon Sep 17 00:00:00 2001 From: Badal Kumar Prusty Date: Thu, 28 Nov 2024 16:22:53 +0530 Subject: [PATCH 4/8] debug-2 --- .github/workflows/pr-issue-validator.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr-issue-validator.yaml b/.github/workflows/pr-issue-validator.yaml index 4a3c0a7c57..b4ab77251a 100644 --- a/.github/workflows/pr-issue-validator.yaml +++ b/.github/workflows/pr-issue-validator.yaml @@ -108,7 +108,7 @@ jobs: extra_args_for_auth="" else echo "Adding extra arguments for authentication: private repository detected." - extra_args_for_auth='--header "Authorization: Bearer ${{ secrets.GH_PR_VALIDATOR_TOKEN }}"' + extra_args_for_auth='--header "authorization: Bearer ${{ secrets.GH_PR_VALIDATOR_TOKEN }}"' fi # Check if the issue exists in the private repo @@ -116,7 +116,7 @@ jobs: echo "Checking extra arguments for authentication: $extra_args_for_auth" - + echo "Response Code: $response_code" if [[ "$response_code" -eq 200 ]]; then echo "Issue #$issue_num is valid and exists in $repo." From 1e7c94211184e8aac1ad9d490e941e124cee2a00 Mon Sep 17 00:00:00 2001 From: Badal Kumar Prusty Date: Thu, 28 Nov 2024 16:34:29 +0530 Subject: [PATCH 5/8] debug-3 --- .github/workflows/pr-issue-validator.yaml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/pr-issue-validator.yaml b/.github/workflows/pr-issue-validator.yaml index b4ab77251a..f9ad7d8d21 100644 --- a/.github/workflows/pr-issue-validator.yaml +++ b/.github/workflows/pr-issue-validator.yaml @@ -102,19 +102,18 @@ jobs: issue_api_url="https://api.github.com/repos/$repo/issues/$issue_num" echo "API URL: $issue_api_url" - extra_args_for_auth="" + extra_args_for_auth=() if [[ $repo == "devtron-labs/devtron" || $repo == "devtron-labs/devtron-services" || $repo == "devtron-labs/dashboard" ]]; then echo "No extra arguments needed: public repository detected." - extra_args_for_auth="" else echo "Adding extra arguments for authentication: private repository detected." - extra_args_for_auth='--header "authorization: Bearer ${{ secrets.GH_PR_VALIDATOR_TOKEN }}"' + extra_args_for_auth=(--header "authorization: Bearer ${{ secrets.GH_PR_VALIDATOR_TOKEN }}") fi - + # Check if the issue exists in the private repo - response_code=$(curl -s -o /dev/null -w "%{http_code}" $extra_args_for_auth "$issue_api_url") + response_code=$(curl -s -o /dev/null -w "%{http_code}" "${extra_args_for_auth[@]}" "$issue_api_url") - echo "Checking extra arguments for authentication: $extra_args_for_auth" + echo "Checking extra arguments for authentication: " "${extra_args_for_auth[@]}" echo "Response Code: $response_code" @@ -122,7 +121,7 @@ jobs: 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 $extra_args_for_auth "$issue_api_url" | jq '.state'|tr -d \") + issue_status=$(curl -s "${extra_args_for_auth[@]}" "$issue_api_url" | jq '.state'|tr -d \") # Check if the issue is still open. if [[ "$issue_status" == open ]]; then echo "Issue #$issue_num is opened." From 3d1421e4b495e59122718bf2acc4345cbec16553 Mon Sep 17 00:00:00 2001 From: Badal Kumar Prusty Date: Thu, 28 Nov 2024 17:11:39 +0530 Subject: [PATCH 6/8] debug-4 --- .github/workflows/pr-issue-validator.yaml | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/.github/workflows/pr-issue-validator.yaml b/.github/workflows/pr-issue-validator.yaml index f9ad7d8d21..95aca2e994 100644 --- a/.github/workflows/pr-issue-validator.yaml +++ b/.github/workflows/pr-issue-validator.yaml @@ -102,26 +102,30 @@ jobs: issue_api_url="https://api.github.com/repos/$repo/issues/$issue_num" echo "API URL: $issue_api_url" - extra_args_for_auth=() if [[ $repo == "devtron-labs/devtron" || $repo == "devtron-labs/devtron-services" || $repo == "devtron-labs/dashboard" ]]; then echo "No extra arguments needed: public repository detected." else echo "Adding extra arguments for authentication: private repository detected." - extra_args_for_auth=(--header "authorization: Bearer ${{ secrets.GH_PR_VALIDATOR_TOKEN }}") + response_code=$(curl -s -o /dev/null -w "%{http_code}" \ + --header "authorization: Bearer ${{ secrets.GH_PR_VALIDATOR_TOKEN }}" \ + "$issue_api_url") fi - - # Check if the issue exists in the private repo - response_code=$(curl -s -o /dev/null -w "%{http_code}" "${extra_args_for_auth[@]}" "$issue_api_url") - - echo "Checking extra arguments for authentication: " "${extra_args_for_auth[@]}" - 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 "${extra_args_for_auth[@]}" "$issue_api_url" | jq '.state'|tr -d \") + if [[ $repo == "devtron-labs/devtron" || $repo == "devtron-labs/devtron-services" || $repo == "devtron-labs/dashboard" ]]; then + echo "No extra arguments needed: public repository detected." + 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") + fi + echo "Issue Status: $issue_status" + # Check if the issue is still open. if [[ "$issue_status" == open ]]; then echo "Issue #$issue_num is opened." From 41df330910074c373f77d056ec91e4c22bcfaf83 Mon Sep 17 00:00:00 2001 From: Badal Kumar Prusty Date: Thu, 28 Nov 2024 17:14:45 +0530 Subject: [PATCH 7/8] debug-5 --- .github/workflows/pr-issue-validator.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-issue-validator.yaml b/.github/workflows/pr-issue-validator.yaml index 95aca2e994..114fda681f 100644 --- a/.github/workflows/pr-issue-validator.yaml +++ b/.github/workflows/pr-issue-validator.yaml @@ -122,7 +122,7 @@ jobs: echo "Adding extra arguments for authentication: private repository detected." issue_status=$(curl -s \ --header "authorization: Bearer ${{ secrets.GH_PR_VALIDATOR_TOKEN }}" \ - "$issue_api_url") + "$issue_api_url"| jq '.state'|tr -d \") fi echo "Issue Status: $issue_status" From 4fc92a246be0e090e90499764ae048f47559d8fe Mon Sep 17 00:00:00 2001 From: Badal Kumar Prusty Date: Thu, 28 Nov 2024 18:38:46 +0530 Subject: [PATCH 8/8] debug-6 --- .github/workflows/pr-issue-validator.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/pr-issue-validator.yaml b/.github/workflows/pr-issue-validator.yaml index 114fda681f..a012d9983b 100644 --- a/.github/workflows/pr-issue-validator.yaml +++ b/.github/workflows/pr-issue-validator.yaml @@ -104,6 +104,9 @@ jobs: 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}" \ @@ -118,6 +121,8 @@ jobs: # Fetch the current state of the issue (open/closed) from the private repository. 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 \