Created
March 3, 2022 08:28
-
-
Save mersanuzun/03dead04b98682cbae10d7990b2ac49d to your computer and use it in GitHub Desktop.
script-keeper-upload.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
MANIFEST_PATH="$3" | |
SRC=$(jq '."app.js"' $MANIFEST_PATH) | |
CHUNK=$(jq '."chunk-vendors.js"' $MANIFEST_PATH) | |
APP_NAME="$1" | |
SCRIPT_KEEPER_API_URL="$2" | |
if [ "$SRC" = null ] || [ ! "$SRC" ] | |
then | |
echo 'Could not find app.js in manifest.json'; | |
exit 1; | |
fi | |
if [ "$APP_NAME" = null ] || [ ! "$APP_NAME" ] | |
then | |
echo 'Could not find APP_NAME'; | |
exit 1; | |
fi | |
if [ "$CHUNK" = null ] | |
then | |
BODY='{ | |
"appName": '"\"$APP_NAME\""', | |
"src": '"$SRC"' | |
}'; | |
else | |
BODY='{ | |
"appName": '"\"$APP_NAME\""', | |
"src": '"$SRC"', | |
"chunk": '"$CHUNK"' | |
}'; | |
fi | |
RESPONSE_CODE=$(curl -L -X POST -o /dev/null -s -w "%{http_code}\n" \ | |
-H "Content-Type: application/json" \ | |
--data-raw "$BODY" \ | |
"$SCRIPT_KEEPER_API_URL"'/script') | |
SUCCESS_RESPONSE_CODE=200 | |
if [ "$RESPONSE_CODE" == $SUCCESS_RESPONSE_CODE ] | |
then echo 'Uploaded successfully'; | |
then | |
echo 'Not Update Fallback Datasource'; | |
exit 1; | |
else | |
echo 'Not Uploaded'; | |
exit 1; | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment