2020-11-20 03:46:29 +00:00
|
|
|
#!/bin/bash
|
2018-02-15 20:08:23 +00:00
|
|
|
set -e
|
|
|
|
|
|
|
|
NETLIFY_SITE=""
|
|
|
|
NETLIFY_DEPLOY_OPTIONS=""
|
|
|
|
|
2022-10-20 21:58:05 +00:00
|
|
|
if [ -n "$PLUGIN_PROD" ] && [ "$PLUGIN_PROD" != false ]
|
2018-02-15 20:08:23 +00:00
|
|
|
then
|
2022-10-20 21:58:05 +00:00
|
|
|
NETLIFY_DEPLOY_OPTIONS="--prod"
|
2018-02-15 20:08:23 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "$PLUGIN_PATH" ]
|
|
|
|
then
|
2022-10-20 21:58:05 +00:00
|
|
|
NETLIFY_DEPLOY_OPTIONS="${NETLIFY_DEPLOY_OPTIONS} --dir ${PLUGIN_PATH}"
|
2018-02-15 20:08:23 +00:00
|
|
|
else
|
2022-10-20 21:58:05 +00:00
|
|
|
NETLIFY_DEPLOY_OPTIONS="${NETLIFY_DEPLOY_OPTIONS} --dir ./"
|
2018-02-15 20:08:23 +00:00
|
|
|
fi
|
|
|
|
|
2018-02-15 21:11:09 +00:00
|
|
|
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
|
|
|
|
|
2022-10-20 21:58:05 +00:00
|
|
|
if [ -n "$PLUGIN_ALIAS" ]
|
2018-02-15 20:08:23 +00:00
|
|
|
then
|
2022-10-20 21:58:05 +00:00
|
|
|
NETLIFY_DEPLOY_OPTIONS="${NETLIFY_DEPLOY_OPTIONS} --alias ${PLUGIN_ALIAS}"
|
|
|
|
elif [ -n "$DRONE_COMMIT_SHA" ]
|
2018-02-15 20:08:23 +00:00
|
|
|
then
|
2022-10-20 21:58:05 +00:00
|
|
|
NETLIFY_DEPLOY_OPTIONS="${NETLIFY_DEPLOY_OPTIONS} --alias ${DRONE_COMMIT_SHA}"
|
2018-02-15 20:08:23 +00:00
|
|
|
fi
|
|
|
|
|
2022-10-21 04:51:58 +00:00
|
|
|
if [ -n "$PLUGIN_DEBUG" ] && [ "$PLUGIN_DEBUG" != false ]
|
|
|
|
then
|
|
|
|
cat netlify.toml
|
|
|
|
NETLIFY_DEPLOY_OPTIONS="${NETLIFY_DEPLOY_OPTIONS} --debug"
|
|
|
|
fi
|
|
|
|
|
2022-12-04 22:43:09 +00:00
|
|
|
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";
|
2018-02-15 20:08:23 +00:00
|
|
|
|
2018-02-15 20:43:33 +00:00
|
|
|
rc=$?;
|
2020-11-19 22:50:47 +00:00
|
|
|
if [[ $rc != 0 ]]
|
2018-02-15 20:43:33 +00:00
|
|
|
then
|
|
|
|
echo "> non-zero exit code $rc" &&
|
|
|
|
exit $rc
|
|
|
|
else
|
|
|
|
echo $'\n'"> Successfully deployed!"$'\n'
|
2020-01-29 01:03:33 +00:00
|
|
|
fi
|