Skip to content

Commit

Permalink
new azure deployment pipeline implemented, with slack notification, 5…
Browse files Browse the repository at this point in the history
… min delay, and environment variable checks.
  • Loading branch information
Alexandru Ianta committed Jun 24, 2021
2 parents 9a3a26a + 13e881d commit d7acfc2
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 73 deletions.
73 changes: 0 additions & 73 deletions azure-pipelines.yml

This file was deleted.

73 changes: 73 additions & 0 deletions dev_deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Dev Deployment Script

echo "Preventing calamity. Please wait while environment variables are verified..."
# ENSURE ENVIRONMENT VARIABLES EXIST, OTHERWISE CRASH # IT'S CRITICAL THIS EXISTS OTHERWISE THE DEPLOYING SERVER WILL GET NUKED!!
if [ -z "${CKAN_LOG_PATH}" ] ||\
[ -z "${CKAN_PORT}" ] ||\
[ -z "${CKAN_SITE_URL}" ] ||\
[ -z "${CKAN_TAG}" ] ||\
[ -z "${CKANEXTS_PATH}" ] ||\
[ -z "${DOCKER_EXTS_PATH}" ] ||\
[ -z "${DOCKER_VENV_PATH}" ] ||\
[ -z "${DOCKER_PATH}" ] ||\
[ -z "${EXT_NAME}" ]
then
echo "Required environment variables not set! Exiting to prevent catastrophic behavior!"
exit 1
fi

echo "CKAN_LOG_PATH: ${CKAN_LOG_PATH}"
echo "CKAN_PORT: ${CKAN_PORT}"
echo "CKAN_TAG: ${CKAN_TAG}"
echo "CKAN_SITE_URL: ${CKAN_SITE_URL}"
echo "CKANEXTS_PATH: ${CKANEXTS_PATH}"
echo "EXT_NAME: ${EXT_NAME}"
echo "DOCKER_PATH: ${DOCKER_PATH}"
echo "DOCKER_VENV_PATH: ${DOCKER_VENV_PATH}"
echo "DOCKER_EXTS_PATH: ${DOCKER_EXTS_PATH}"

# COPY PLUGIN FILES
echo "Cloned repo into ${AGENT_RELEASEDIRECTORY}/${RELEASE_PRIMARYARTIFACTSOURCEALIAS}"
echo "Repo contents:"
ls ${AGENT_RELEASEDIRECTORY}/${RELEASE_PRIMARYARTIFACTSOURCEALIAS}

# If the extension folder does not exist create it.
if [ ! -d ${CKANEXTS_PATH}${EXT_NAME} ]
then
echo "Extension folder does not exist, creating it now."
sudo mkdir ${CKANEXTS_PATH}${EXT_NAME}
else
echo "Extension folder exists, clearing old contents in ${CKANEXTS_PATH}${EXT_NAME}"
sudo rm -r ${CKANEXTS_PATH}${EXT_NAME}
sudo mkdir ${CKANEXTS_PATH}${EXT_NAME}
fi
echo "Copying new files"
sudo cp -r ${AGENT_RELEASEDIRECTORY}/${RELEASE_PRIMARYARTIFACTSOURCEALIAS}/* ${CKANEXTS_PATH}${EXT_NAME}
sudo chmod 777 -R ${CKANEXTS_PATH}${EXT_NAME}

echo "Installing plugin into CKAN venv"
sudo docker exec ckan /bin/bash -c "source ${DOCKER_VENV_PATH} && \
cd ${DOCKER_EXTS_PATH}${EXT_NAME}/ && pip install -r requirements.txt"
sudo docker exec ckan /bin/bash -c "source ${DOCKER_VENV_PATH} && \
cd ${DOCKER_EXTS_PATH}${EXT_NAME}/ && python setup.py develop"

# SHUTDOWN CKAN
cd ${DOCKER_PATH}
sudo docker-compose down

# RESTART CKAN
cd ${DOCKER_PATH}
sudo docker-compose up -d

# SEED VITALITY AUTHORIZATION MODEL
echo "Seeding users into metadata authorization model"
sudo docker exec ckan /usr/local/bin/ckan-paster --plugin=${EXT_NAME} \
vitality seed --config=/etc/ckan/production.ini

# RE-INDEX DATASETS
echo "Re-indexing datasets..."
sudo docker exec ckan /usr/local/bin/ckan-paster --plugin=ckan search-index \
rebuild --config=/etc/ckan/production.ini

sudo docker exec ckan /usr/local/bin/ckan-paster --plugin=ckanext-harvest harvester \
reindex --config=/etc/ckan/production.ini

0 comments on commit d7acfc2

Please sign in to comment.