forked from roots/trellis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.sh
executable file
·36 lines (27 loc) · 853 Bytes
/
deploy.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
#!/bin/bash
shopt -s nullglob
DEPLOY_CMD="ansible-playbook -i hosts/$1 deploy.yml --extra-vars="site=$2""
ENVIRONMENTS=( hosts/* )
ENVIRONMENTS=( "${ENVIRONMENTS[@]##*/}" )
NUM_ARGS=2
show_usage() {
echo "Usage: deploy <environment> <site name>
<environment> is the environment to deploy to ("staging", "production", etc)
<site name> is the WordPress site to deploy (name defined in "wordpress_sites")
Available environments:
`( IFS=$'\n'; echo "${ENVIRONMENTS[*]}" )`
Examples:
deploy staging example.com
deploy production example.com
"
}
HOSTS_FILE="hosts/$1"
[[ $# -ne $NUM_ARGS || $1 = -h ]] && { show_usage; exit 0; }
if [[ ! -e $HOSTS_FILE ]]; then
echo "Error: $1 is not a valid environment ($HOSTS_FILE does not exist)."
echo
echo "Available environments:"
( IFS=$'\n'; echo "${ENVIRONMENTS[*]}" )
exit 0
fi
$DEPLOY_CMD