Last active
May 7, 2023 09:15
-
-
Save bgarcial/7630996b4acf6c957039a3b0e4085431 to your computer and use it in GitHub Desktop.
Deploying AppEngine Services
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##################################################### | |
# Function deploys an appengine artifact | |
# Globals: | |
# None | |
# Arguments: | |
# 1:PACKAGE | |
# 2:VERSION | |
# 3:ENVIRONMENT | |
# 4:SHADOW | |
# Returns: | |
# None | |
##################################################### | |
deployAppengine() { | |
local PACKAGE=$1 | |
local VERSION=$2 | |
local ENVIRONMENT=$3 | |
local SHADOW=$4 | |
local RUNTIME_DIR=${PROJECT_DIR}/runtimes | |
RES=0 | |
showLine | |
RES=$(checkOkState $?) | |
showLine | |
echoinf "Deploy Configuration for ${PACKAGE}" | |
showLine | |
echoinf "RUNTIME_DIR: ${RUNTIME_DIR}" | |
echoinf "PACKAGE: ${PACKAGE}" | |
echoinf "VERSION: ${VERSION}" | |
echoinf "ENVIRONMENT: ${ENVIRONMENT}" | |
echoinf "SHADOW: ${SHADOW}" | |
local FORCE_REBUILD=false | |
echoinf "Generate URLS..." | |
local URLS=($(generateConsoleAndAPIURL ${ENVIRONMENT} ${VERSION} ${SHADOW})) | |
local API_URL=${URLS[0]} | |
local CONSOLE_URL=${URLS[1]} | |
local API_HOST=${URLS[2]} | |
local PROTOCOL=${URLS[3]} | |
echoinf "API URL: ${API_URL}" | |
echoinf "CONSOLE URL: ${CONSOLE_URL}" | |
echoinf "API_HOST: ${API_HOST}" | |
# only build if running locally and not on CI as the build is always a previous step there | |
if [[ -z ${CI} ]]; then | |
buildVE "appengine" ${ENVIRONMENT} ${FORCE_REBUILD} | |
RES=$(checkOkState $?) | |
fi | |
local VE_DIR=${RUNTIME_DIR}/.venv/appengine | |
activate "appengine" | |
echoinf "Build finished, creating and deploying swagger spec..." | |
createAndDeploySwaggerSpec ${ENVIRONMENT} ${VERSION} ${SHADOW} | |
RES=$(checkOkState $?) | |
if [[ ${RES} -ne 0 ]]; then return 1; fi | |
local service_pids+=" ${!}" | |
local services=$(echo ${full_args["appengine-services"]} | sed -e 's/\"//g') | |
for SERVICE in ${services}; do | |
if [[ ${SERVICE} == "default" ]]; then | |
# Only build console for package default | |
buildVE "console" ${ENVIRONMENT} | |
RES=$(checkOkState $?) | |
if [[ ${RES} -ne 0 ]]; then return 1; fi | |
fi | |
local services_py3=$(echo ${full_args["appengine-py3-services"]} | sed -e 's/\"//g') | |
if [[ "$services_py3" == *"$SERVICE"* ]]; then | |
continue | |
fi | |
echoinf "Deploying Python Appengine service ${SERVICE} with version ${VERSION} to ${ENVIRONMENT}..." | |
echoinf gcloud beta app deploy -q ${PROJECT_DIR}/packages/placeholdername/gae/${SERVICE}.yaml --configuration ${ENVIRONMENT} --version ${VERSION} | |
(gcloud beta app deploy -q ${PROJECT_DIR}/packages/placeholdername/gae/${SERVICE}.yaml --configuration ${ENVIRONMENT} --version ${VERSION}) & | |
service_pids+=" ${!}" | |
done | |
for P in ${service_pids}; do | |
wait ${P} || rc=$? | |
PIDS=${service_pids/${P} /} | |
if [[ ${rc} -ne 0 ]]; then | |
RES=$(checkOkState $rc) | |
if [[ ${RES} -ne 0 ]]; then return 1; fi | |
fi | |
done | |
echoinf "Deployment of Appengine done" | |
showLine | |
return ${RES} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment