Skip to content

Commit 35b5f36

Browse files
committed
fix: curl api for forked
1 parent 14f2051 commit 35b5f36

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

.github/workflows/pr-validator.yaml

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,8 @@ jobs:
3030
BASE_REPO: ${{ github.event.pull_request.base.repo.full_name }}
3131
HEAD_REPO: ${{ github.event.pull_request.head.repo.full_name }}
3232
run: |
33-
echo "Token value: $GH_PR_VALIDATOR_TOKEN"
3433
echo "base or target repo : ${{ github.event.pull_request.base.repo.full_name }}"
3534
echo "head or source repo : ${{ github.event.pull_request.head.repo.full_name }}"
36-
echo "$GH_PR_VALIDATOR_TOKEN" | gh auth login --with-token
3735
3836
if [[ ${{ github.event.pull_request.head.repo.full_name }} == ${{ github.event.pull_request.base.repo.full_name }} ]]; then
3937
export forked=false
@@ -46,8 +44,24 @@ jobs:
4644
if [[ "$TITLE" =~ ^(doc:|docs:|chore:|misc:|Release:|release:|Sync:|sync:) ]]; then
4745
echo "Skipping validation for docs/chore PR."
4846
echo "PR NUMBER-: $PRNUM "
49-
gh pr edit $PRNUM --remove-label "PR:Issue-verification-failed"
50-
gh pr edit $PRNUM --add-label "PR:Ready-to-Review"
47+
if [[ "$forked" == "false" ]]; then
48+
gh pr edit $PRNUM --remove-label "PR:Issue-verification-failed"
49+
gh pr edit $PRNUM --add-label "PR:Ready-to-Review"
50+
else
51+
curl -L \
52+
-X POST \
53+
-H "Accept: application/vnd.github+json" \
54+
-H "X-GitHub-Api-Version: 2022-11-28" \
55+
https://api.github.com/repos/devtron-labs/${{ github.event.repository.name }}/issues/${{ github.event.pull_request.number }}/labels \
56+
-d '{"labels":["PR:Ready-to-Review"]}'
57+
58+
59+
60+
curl -X DELETE \
61+
-H "Accept: application/vnd.github+json" \
62+
-H "X-GitHub-Api-Version: 2022-11-28" \
63+
https://api.github.com/repos/devtron-labs/${{ github.event.repository.name }}/issues/${{ github.event.pull_request.number }}/labels/PR:Issue-verification-failed"
64+
fi
5165
exit 0
5266
fi
5367
@@ -111,7 +125,7 @@ jobs:
111125
response=$(curl -s -w "%{http_code}" --header "Authorization: Bearer ${{ secrets.GH_PR_VALIDATOR_TOKEN }}" \
112126
--header "Accept: application/vnd.github+json" "$issue_api_url")
113127
fi
114-
128+
{"labels":["PR:Ready-to-Review"]}
115129
# Extract HTTP status code from the response
116130
response_code=$(echo "$response" | tail -n 1) # Status code is the last line
117131
response_body=$(echo "$response" | head -n -1) # The body is everything except the last line (status code)

0 commit comments

Comments
 (0)