Skip to content

Instantly share code, notes, and snippets.

@mersanuzun
Created March 3, 2022 08:28
Show Gist options
  • Save mersanuzun/03dead04b98682cbae10d7990b2ac49d to your computer and use it in GitHub Desktop.
Save mersanuzun/03dead04b98682cbae10d7990b2ac49d to your computer and use it in GitHub Desktop.
script-keeper-upload.sh
#!/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