Browse Source

Add Azure Pipelines CD

pull/208/head
Clemens Wolff 5 years ago
parent
commit
dd57112ff6
2 changed files with 41 additions and 0 deletions
  1. 10
      azure-pipelines.yaml
  2. 31
      tools/azure.sh

10
azure-pipelines.yaml

@ -11,3 +11,13 @@ steps:
- script: DOCKER_PASSWORD="$(docker_password)" tools/cd.sh "azdo-$(Build.BuildId)"
displayName: 'Push docker image'
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'), ne(variables['docker_password'], ''))
- script: |
az login --service-principal --password "$(auth_password)" --tenant "$(auth_tenant)" --username "$(auth_username)"
DOCCANO_ADMIN_PASSWORD="$(doccano_admin_password)" \
DOCCANO_SECRET_KEY="$(doccano_secret_key)" \
DOCKER_PASSWORD="$(docker_password)" \
tools/azure.sh "azdo-$(Build.BuildId)"
displayName: 'Deploy to Azure'
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'), ne(variables['auth_password'], ''))

31
tools/azure.sh

@ -0,0 +1,31 @@
#!/usr/bin/env bash
set -o errexit
if [[ -z "${DOCCANO_LOCATION}" ]]; then echo "Missing DOCCANO_LOCATION environment variable" >&2; exit 1; fi
if [[ -z "${DOCCANO_RESOURCE_GROUP}" ]]; then echo "Missing DOCCANO_LOCATION environment variable" >&2; exit 1; fi
if [[ -z "${DOCCANO_APP_NAME}" ]]; then echo "Missing DOCCANO_APP_NAME environment variable" >&2; exit 1; fi
if [[ -z "${DOCCANO_SECRET_KEY}" ]]; then echo "Missing DOCCANO_SECRET_KEY environment variable" >&2; exit 1; fi
if [[ -z "${DOCCANO_ADMIN_USERNAME}" ]]; then echo "Missing DOCCANO_ADMIN_USERNAME environment variable" >&2; exit 1; fi
if [[ -z "${DOCCANO_ADMIN_CONTACT_EMAIL}" ]]; then echo "Missing DOCCANO_ADMIN_CONTACT_EMAIL environment variable" >&2; exit 1; fi
if [[ -z "${DOCCANO_ADMIN_PASSWORD}" ]]; then echo "Missing DOCCANO_ADMIN_PASSWORD environment variable" >&2; exit 1; fi
if ! az account show >/dev/null; then echo "Must be logged into Azure" >&2; exit 2; fi
az group create \
--location "${DOCCANO_LOCATION}" \
--name "${DOCCANO_RESOURCE_GROUP}"
az group deployment create \
--resource-group "${DOCCANO_RESOURCE_GROUP}" \
--name "azuredeploy$1" \
--parameters \
appName="${DOCCANO_APP_NAME}" \
secretKey="${DOCCANO_SECRET_KEY}" \
adminUserName="${DOCCANO_ADMIN_USERNAME}" \
adminContactEmail="${DOCCANO_ADMIN_CONTACT_EMAIL}" \
adminPassword="${DOCCANO_ADMIN_PASSWORD}" \
dockerImageName="${DOCKER_REGISTRY:-${DOCKER_USERNAME:-chakkiworks}}/doccano:${1:-latest}" \
dockerRegistry="${DOCKER_REGISTRY}" \
dockerRegistryUserName="${DOCKER_USERNAME}" \
dockerRegistryPassword="${DOCKER_PASSWORD}" \
--template-file azuredeploy.json
Loading…
Cancel
Save