-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdeploy-apigee.sh
More file actions
executable file
·51 lines (39 loc) · 1.54 KB
/
deploy-apigee.sh
File metadata and controls
executable file
·51 lines (39 loc) · 1.54 KB
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
#!/bin/bash
set -e
ORG=entur
NAME=mummu
function deploy {
ENV="${1:-dev}"
if ! [[ "$ENV" =~ ^(dev|staging|prod)$ ]]; then
echo -e " 🙈 Invalid ENV: $ENV\n"
exit 1
fi
read -rp " 😺 Apigee user: " APIGEEUSER
read -rsp " 🔑 Apigee password: " APIGEEPASSWORD
echo
if ! command_exists jq; then
brew install jq
fi
if [[ "$ENV" == "dev" ]]; then
echo " 📝 Deploying new revision to Apigee dev ..."
apigeetool deployproxy -V -o $ORG -e dev -n $NAME -d api/mummu -u $APIGEEUSER -p $APIGEEPASSWORD
fi
APIGEEREVISION=$(apigeetool listdeployments -u $APIGEEUSER -p $APIGEEPASSWORD -o $ORG -n $NAME -j | jq '.deployments[] | select(.environment |contains("dev")) |.revision' | tail -1)
if [[ "$ENV" == "staging" ]]; then
echo " 📝 Deploying revision $APIGEEREVISION to Apigee stage ..."
apigeetool deployExistingRevision -V -u $APIGEEUSER -p $APIGEEPASSWORD -o $ORG -e stage -n $NAME -r $APIGEEREVISION
elif [[ "$ENV" == "prod" ]]; then
echo " 📝 Deploying revision $APIGEEREVISION to Apigee prod ..."
apigeetool deployExistingRevision -V -u $APIGEEUSER -p $APIGEEPASSWORD -o $ORG -e prod -n $NAME -r $APIGEEREVISION
fi
echo -e "\n 🎉 Revision $APIGEEREVISION successfully deployed to $ENV!"
echo -e "\n 📋 Status: https://apigee.com/platform/$ORG/proxies/$NAME/overview/$APIGEEREVISION"
}
function command_exists {
command -v $1 >/dev/null 2>&1;
}
ENV_ARGS="${@:-dev}"
for ENV_ARG in $ENV_ARGS
do
deploy "$ENV_ARG"
done