mirror of https://github.com/doccano/doccano.git
Browse Source
Merge pull request #208 from CatalystCode/enhancement/azure-pipelines
Merge pull request #208 from CatalystCode/enhancement/azure-pipelines
Enhancement/Integrate with Azure Pipelinespull/215/head
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 137 additions and 4 deletions
Split View
Diff Options
-
1.gitignore
-
2app/app/settings.py
-
54azure-pipelines.yaml
-
43azuredeploy.json
-
1requirements.txt
-
31tools/azure.sh
-
9tools/cd.sh
@ -0,0 +1,54 @@ |
|||
trigger: |
|||
- master |
|||
|
|||
pool: |
|||
vmImage: 'ubuntu-latest' |
|||
|
|||
steps: |
|||
- script: docker build --tag=doccano --target=builder . |
|||
displayName: 'Run tests' |
|||
|
|||
- script: docker run doccano tar Ccf /doccano/app - junitxml | tar Cxf "$(Build.ArtifactStagingDirectory)" - |
|||
displayName: 'Export test results' |
|||
|
|||
- task: PublishTestResults@2 |
|||
inputs: |
|||
testResultsFormat: 'JUnit' |
|||
testResultsFiles: 'TEST-*.xml' |
|||
searchFolder: '$(Build.ArtifactStagingDirectory)/junitxml' |
|||
mergeTestResults: true |
|||
testRunTitle: 'server.tests' |
|||
displayName: 'Publish test results' |
|||
|
|||
# To publish docker images to a container registry, set the following pipeline variables: |
|||
# - docker_password |
|||
# - docker_username |
|||
# - docker_registry (optional, set this to publish to a registry other than Docker Hub) |
|||
# |
|||
- 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'], '')) |
|||
|
|||
# To automatically deploy to Azure, create a service principal and set the following pipeline variables: |
|||
# - auth_username (app ID) |
|||
# - auth_tenant (tenant ID |
|||
# - auth_password (secret) |
|||
# |
|||
# Additionally, to configure the deployment, set the following pipeline variables: |
|||
# - doccano_admin_username |
|||
# - doccano_admin_password |
|||
# - doccano_admin_contact_email |
|||
# - doccano_app_name (globally unique name for the app) |
|||
# - doccano_secret_key (pass-through secret for Django) |
|||
# - doccano_resource_group (group for all resources, will be created if it doesn't yet exist) |
|||
# - doccano_location (name of the Azure region to which to deploy all resources) |
|||
# |
|||
- 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'], '')) |
@ -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 |
Write
Preview
Loading…
Cancel
Save