Skip to content

Commit 0e623dc

Browse files
committed
refactor(extraction): replace gh calls with curl/jq
1 parent ad38af4 commit 0e623dc

File tree

1 file changed

+24
-11
lines changed

1 file changed

+24
-11
lines changed

.github/workflows/design-extraction.yml

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ jobs:
4040
echo "::error::No PR number provided"
4141
exit 1
4242
fi
43-
PR_JSON=$(gh api "repos/${{ github.repository }}/pulls/${PR_NUMBER}")
43+
PR_JSON=$(curl -fsSL \
44+
-H "Authorization: Bearer $GH_TOKEN" \
45+
-H "Accept: application/vnd.github+json" \
46+
"https://api.github.com/repos/${{ github.repository }}/pulls/${PR_NUMBER}")
4447
echo "number=${PR_NUMBER}" >> "$GITHUB_OUTPUT"
4548
echo "title=$(echo "$PR_JSON" | jq -r '.title')" >> "$GITHUB_OUTPUT"
4649
echo "head_sha=$(echo "$PR_JSON" | jq -r '.head.sha')" >> "$GITHUB_OUTPUT"
@@ -136,15 +139,21 @@ jobs:
136139
env:
137140
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
138141
run: |
139-
COMMENTS=$(gh api --paginate \
140-
"repos/${{ github.repository }}/issues/${{ steps.pr.outputs.number }}/comments" \
141-
--jq '[.[] | "**@\(.user.login):** \(.body | .[0:2000])"] | join("\n\n---\n\n")')
142-
REVIEW_COMMENTS=$(gh api --paginate \
143-
"repos/${{ github.repository }}/pulls/${{ steps.pr.outputs.number }}/comments" \
144-
--jq '[.[] | "**@\(.user.login) (review on \(.path)):** \(.body | .[0:2000])"] | join("\n\n---\n\n")')
145-
REVIEWS=$(gh api --paginate \
146-
"repos/${{ github.repository }}/pulls/${{ steps.pr.outputs.number }}/reviews" \
147-
--jq '[.[] | select(.body != "") | "**@\(.user.login) (\(.state)):** \(.body | .[0:2000])"] | join("\n\n---\n\n")')
142+
COMMENTS=$(curl -fsSL \
143+
-H "Authorization: Bearer $GH_TOKEN" \
144+
-H "Accept: application/vnd.github+json" \
145+
"https://api.github.com/repos/${{ github.repository }}/issues/${{ steps.pr.outputs.number }}/comments?per_page=100" \
146+
| jq -r '[.[] | "**@\(.user.login):** \(.body | .[0:2000])"] | join("\n\n---\n\n")')
147+
REVIEW_COMMENTS=$(curl -fsSL \
148+
-H "Authorization: Bearer $GH_TOKEN" \
149+
-H "Accept: application/vnd.github+json" \
150+
"https://api.github.com/repos/${{ github.repository }}/pulls/${{ steps.pr.outputs.number }}/comments?per_page=100" \
151+
| jq -r '[.[] | "**@\(.user.login) (review on \(.path)):** \(.body | .[0:2000])"] | join("\n\n---\n\n")')
152+
REVIEWS=$(curl -fsSL \
153+
-H "Authorization: Bearer $GH_TOKEN" \
154+
-H "Accept: application/vnd.github+json" \
155+
"https://api.github.com/repos/${{ github.repository }}/pulls/${{ steps.pr.outputs.number }}/reviews?per_page=100" \
156+
| jq -r '[.[] | select(.body != "") | "**@\(.user.login) (\(.state)):** \(.body | .[0:2000])"] | join("\n\n---\n\n")')
148157
COMBINED=$(printf '%s\n\n%s\n\n%s' "$COMMENTS" "$REVIEW_COMMENTS" "$REVIEWS")
149158
DELIM="PR_COMMENTS_$(date +%s%N)"
150159
if printf '%s' "$COMBINED" | grep -qF "$DELIM"; then
@@ -215,4 +224,8 @@ jobs:
215224
env:
216225
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
217226
run: |
218-
gh pr edit "${{ steps.pr.outputs.number }}" --add-label "design-extracted"
227+
curl -fsSL -X POST \
228+
-H "Authorization: Bearer $GH_TOKEN" \
229+
-H "Accept: application/vnd.github+json" \
230+
"https://api.github.com/repos/${{ github.repository }}/issues/${{ steps.pr.outputs.number }}/labels" \
231+
-d '{"labels":["design-extracted"]}'

0 commit comments

Comments
 (0)