Skip to content

Commit

Permalink
Add script
Browse files Browse the repository at this point in the history
  • Loading branch information
anngvu committed Nov 26, 2024
1 parent dfcf96f commit 0223e60
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/register-schema.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

for FILE in $1
do
# Synapse does not allow additionalProperties in schema, so remove that first
jq 'del(.additionalProperties)' $FILE > temp.json
REQUEST_BODY=$(jq '{schema : ., concreteType: "org.sagebionetworks.repo.model.schema.CreateSchemaRequest", dryRun: false }' temp.json)
RESPONSE=$(curl -X POST https://repo-prod.prod.sagebase.org/repo/v1/schema/type/create/async/start \
-H "Authorization: Bearer $SYNAPSE_AUTH_TOKEN" \
-H "Content-Type: application/json" \
-d "$REQUEST_BODY")
rm temp.json

# Will error if token not within response
echo $RESPONSE
TOKEN=$( echo $RESPONSE | jq -e -r '.token')
sleep 1
STATUS=$(curl "https://repo-prod.prod.sagebase.org/repo/v1/schema/type/create/async/get/$TOKEN" \
-H "Authorization: Bearer $SYNAPSE_AUTH_TOKEN")
while true; do
if echo "$STATUS" | jq -e '.jobState == "PROCESSING"' > /dev/null; then
sleep 1
STATUS=$(curl "https://repo-prod.prod.sagebase.org/repo/v1/schema/type/create/async/get/$TOKEN" \
-H "Authorization: Bearer $SYNAPSE_AUTH_TOKEN")
elif echo "$STATUS" | jq -e '.concreteType == "org.sagebionetworks.repo.model.ErrorResponse"' > /dev/null; then
echo "Error: $(echo $STATUS | jq -r '.reason')"
exit 1
else
echo "Success:"
echo "$STATUS" | jq -e '.newVersionInfo'
break
fi
done

0 comments on commit 0223e60

Please sign in to comment.