57 lines
1.3 KiB
Bash
Executable File
57 lines
1.3 KiB
Bash
Executable File
#!/bin/bash
|
|
set -e
|
|
|
|
NETLIFY_SITE=""
|
|
NETLIFY_DEPLOY_OPTIONS=""
|
|
|
|
if [ -n "$PLUGIN_PROD" ] && [ "$PLUGIN_PROD" != false ]
|
|
then
|
|
NETLIFY_DEPLOY_OPTIONS="--prod"
|
|
fi
|
|
|
|
if [ -n "$PLUGIN_PATH" ]
|
|
then
|
|
NETLIFY_DEPLOY_OPTIONS="${NETLIFY_DEPLOY_OPTIONS} --dir ${PLUGIN_PATH}"
|
|
else
|
|
NETLIFY_DEPLOY_OPTIONS="${NETLIFY_DEPLOY_OPTIONS} --dir ./"
|
|
fi
|
|
|
|
if [ -z "$PLUGIN_TOKEN" ]
|
|
then
|
|
if [ -z "$NETLIFY_TOKEN" ]
|
|
then
|
|
echo "> Error! token or netlify_token secret is required"
|
|
exit 1;
|
|
else
|
|
PLUGIN_TOKEN="$NETLIFY_TOKEN"
|
|
fi
|
|
fi
|
|
|
|
if [ -n "$PLUGIN_ALIAS" ]
|
|
then
|
|
NETLIFY_DEPLOY_OPTIONS="${NETLIFY_DEPLOY_OPTIONS} --alias ${PLUGIN_ALIAS}"
|
|
elif [ -n "$DRONE_COMMIT_SHA" ]
|
|
then
|
|
NETLIFY_DEPLOY_OPTIONS="${NETLIFY_DEPLOY_OPTIONS} --alias ${DRONE_COMMIT_SHA}"
|
|
fi
|
|
|
|
if [ -n "$PLUGIN_DEBUG" ] && [ "$PLUGIN_DEBUG" != false ]
|
|
then
|
|
cat netlify.toml
|
|
NETLIFY_DEPLOY_OPTIONS="${NETLIFY_DEPLOY_OPTIONS} --debug"
|
|
fi
|
|
|
|
NETLIFY_AUTH="--auth $PLUGIN_TOKEN"
|
|
echo "> Deploying on Netlify..." &&
|
|
echo "> (Using options $NETLIFY_DEPLOY_OPTIONS)" &&
|
|
netlify deploy $NETLIFY_AUTH $NETLIFY_DEPLOY_OPTIONS --message "$DRONE_COMMIT_MESSAGE";
|
|
|
|
rc=$?;
|
|
if [[ $rc != 0 ]]
|
|
then
|
|
echo "> non-zero exit code $rc" &&
|
|
exit $rc
|
|
else
|
|
echo $'\n'"> Successfully deployed!"$'\n'
|
|
fi
|