-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathscript.sh
executable file
·65 lines (56 loc) · 1.41 KB
/
script.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/sh
set -e
NETLIFY_SITE=""
NETLIFY_DEPLOY_OPTIONS=""
NETLIFY_UPDATE_OPTIONS=""
if [ -n "$PLUGIN_ENVIRONMENT" ]
then
NETLIFY_DEPLOY_OPTIONS="-e ${PLUGIN_ENVIRONMENT}"
NETLIFY_UPDATE_OPTIONS="${NETLIFY_DEPLOY_OPTIONS}"
fi
if [ -n "$PLUGIN_PATH" ]
then
NETLIFY_DEPLOY_OPTIONS="${NETLIFY_DEPLOY_OPTIONS} -p ${PLUGIN_PATH}"
else
NETLIFY_DEPLOY_OPTIONS="${NETLIFY_DEPLOY_OPTIONS} -p ./"
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_SITE_ID" ] && [ -n "$PLUGIN_TOKEN" ]
then
NETLIFY_SITE="-t $PLUGIN_TOKEN -s $PLUGIN_SITE_ID"
echo "> Deploying on Netlify…" &&
netlify $NETLIFY_SITE deploy $NETLIFY_DEPLOY_OPTIONS;
else
echo "> Error! site_id and token are required"
exit 1
fi
if [ -n "$PLUGIN_SITE_NAME" ]
then
NETLIFY_UPDATE_OPTIONS="${NETLIFY_UPDATE_OPTIONS} -n ${PLUGIN_SITE_NAME}"
fi
if [ -n "$PLUGIN_DOMAIN" ]
then
NETLIFY_UPDATE_OPTIONS="${NETLIFY_UPDATE_OPTIONS} -d ${PLUGIN_DOMAIN}"
fi
if [ -n "$PLUGIN_SITE_NAME" ] || [ -n "$PLUGIN_DOMAIN" ]
then
echo "> Updating your Netlify site…" &&
netlify $NETLIFY_SITE update $NETLIFY_UPDATE_OPTIONS;
fi
rc=$?;
if [[ $rc != 0 ]];
then
echo "> non-zero exit code $rc" &&
exit $rc
else
echo $'\n'"> Successfully deployed!"$'\n'
fi