File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -88,6 +88,7 @@ create_pull_request() {
88
88
REPO_URL=" https://api.${INPUT_GITHUB_BASE_URL} /repos/${GITHUB_REPOSITORY} "
89
89
fi
90
90
91
+ ORG_NAME=$( echo " ${GITHUB_REPOSITORY} " | cut -d' /' -f1)
91
92
PULLS_URL=" ${REPO_URL} /pulls"
92
93
93
94
auth_status=$( curl -sL --write-out ' %{http_code}' --output /dev/null -H " ${AUTH_HEADER} " -H " ${HEADER} " " ${PULLS_URL} " )
@@ -110,9 +111,17 @@ create_pull_request() {
110
111
fi
111
112
fi
112
113
113
- PULL_REQUESTS_QUERY_PARAMS=" ?base=${BASE_BRANCH} &head=${BRANCH} "
114
+ pull_requests_response=$( curl -sSL -w " %{http_code}" -H " ${AUTH_HEADER} " -H " ${HEADER} " -X GET " ${PULLS_URL} ?base=${BASE_BRANCH} &head=${ORG_NAME} :${BRANCH} " )
115
+ http_code=" ${pull_requests_response: -3} "
116
+ response_body=" ${pull_requests_response% ???} "
114
117
115
- PULL_REQUESTS=$( echo " $( curl -sSL -H " ${AUTH_HEADER} " -H " ${HEADER} " -X GET " ${PULLS_URL}${PULL_REQUESTS_QUERY_PARAMS} " ) " | jq --raw-output ' .[] | .head.ref ' )
118
+ if [ " $http_code " -ne 200 ]; then
119
+ echo " Error: Failed to fetch pull requests. HTTP status: $http_code "
120
+ echo " Response: $response_body "
121
+ exit 1
122
+ fi
123
+
124
+ PULL_REQUESTS=$( echo " $response_body " | jq --raw-output ' .[] | .head.ref' )
116
125
117
126
if echo " $PULL_REQUESTS " | grep -xq " $BRANCH " ; then
118
127
echo " PULL REQUEST ALREADY EXIST"
You can’t perform that action at this time.
0 commit comments