Skip to content

Commit

Permalink
API Zoo Index Github Actions Fix (#261)
Browse files Browse the repository at this point in the history
This PR updates the github actions responsible for updating and
validating API Zoo Index entries to handle very large files. The
previously used curl requests were exceeding the max request size limit
for large files, so the actions were changed to use a temporary file and
the curl `--data-binary` option.

---------

Co-authored-by: Raman Varma <[email protected]>
  • Loading branch information
ramanv0 and Raman Varma authored Mar 15, 2024
1 parent cc2eacd commit 3a811d7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/push-apizoo-updates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ jobs:
DATA=$(jq -c . < "$FILE")
FILE_URL="${REPO_URL}${FILE}"
JSON_BODY=$(jq --arg file_url "$FILE_URL" 'if type == "array" then map(. + {"file_url": $file_url}) else . + {"file_url": $file_url} end' <<< "$DATA")
RESPONSE=$(curl -s -w "\n%{http_code}" -X POST -H "Content-Type: application/json" -H "Authorization: Bearer ${{ secrets.APIZOO_UPDATE_TOKEN }}" -d "$JSON_BODY" https://apizooindex.gorilla-llm.com/api/update)
TMP_FILE=$(mktemp)
echo "$JSON_BODY" > "$TMP_FILE"
RESPONSE=$(curl -s -w "\n%{http_code}" -X POST -H "Content-Type: application/json" -H "Authorization: Bearer ${{ secrets.APIZOO_UPDATE_TOKEN }}" --data-binary "@$TMP_FILE" https://apizooindex.gorilla-llm.com/api/update)
BODY=$(echo "$RESPONSE" | head -n -1)
HTTP_STATUS=$(echo "$RESPONSE" | tail -n1)
if [ "$HTTP_STATUS" -ne 200 ]; then
Expand All @@ -40,6 +42,7 @@ jobs:
done <<< "$BODY"
ISSUE_BODY+="\`\`\`\n\n"
fi
rm "$TMP_FILE"
done
if [ "$ERROR_FLAG" -eq 1 ]; then
echo "ISSUE_BODY<<EOF" >> $GITHUB_ENV
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/validate-apizoo-contribution.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ jobs:
ISSUE_BODY=""
for FILE in $FILES; do
DATA=$(jq -c . < "$FILE")
RESPONSE=$(curl -s -w "\n%{http_code}" -X POST -H "Content-Type: application/json" -d "$DATA" https://apizooindex.gorilla-llm.com/api/validate)
TMP_FILE=$(mktemp)
echo "$DATA" > "$TMP_FILE"
RESPONSE=$(curl -s -w "\n%{http_code}" -X POST -H "Content-Type: application/json" --data-binary "@$TMP_FILE" https://apizooindex.gorilla-llm.com/api/validate)
rm "$TMP_FILE"
BODY=$(echo "$RESPONSE" | head -n -1)
HTTP_STATUS=$(echo "$RESPONSE" | tail -n1)
echo "Validation response for $FILE: $RESPONSE"
Expand Down

0 comments on commit 3a811d7

Please sign in to comment.