diff options
| author | 2018-11-16 11:28:54 +0000 | |
|---|---|---|
| committer | 2018-11-16 11:28:54 +0000 | |
| commit | a27dca2d9be052e5fdf0156f9a0e2b8a6fe23c19 (patch) | |
| tree | c058d82c07cb956d6dd8ebeb0b275dabf6fb6fc9 | |
| parent | Azure: Should use sudo; we don't run as root (diff) | |
Azure: Build and push container
| -rw-r--r-- | azure-pipelines.yml | 21 | ||||
| -rw-r--r-- | scripts/deploy-azure.sh | 24 | 
2 files changed, 45 insertions, 0 deletions
diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 2b8c9b9c9..3f063ea41 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -23,6 +23,7 @@ jobs:      displayName: 'Install base dependencies'    - task: UsePythonVersion@0 +    displayName: 'Set Python version'      inputs:        versionSpec: '3.7.x'         addToPath: true  @@ -35,3 +36,23 @@ jobs:    - script: python -m flake8      displayName: 'Run linter' + +- job: build +  displayName: 'Build containers' +   +  trigger: +    branches: +      include: +        - master +   +  steps: +  - task: Docker@1 +    displayName: 'Login: Docker Hub' + +    inputs: +      containerregistrytype: 'Container Registry' +      dockerRegistryEndpoint: 'Docker Hub' +      command: 'login' + +  - bash: sh scripts/deploy-azure.sh +    displayName: 'Build and deploy containers' diff --git a/scripts/deploy-azure.sh b/scripts/deploy-azure.sh new file mode 100644 index 000000000..f18407c8b --- /dev/null +++ b/scripts/deploy-azure.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +changed_lines=$(git diff HEAD~1 HEAD docker/base.Dockerfile | wc -l) + +if [ $changed_lines != '0' ]; then +    echo "base.Dockerfile was changed" + +    echo "Building bot base" +    docker build -t pythondiscord/bot-base:latest -f docker/base.Dockerfile . + +    echo "Pushing image to Docker Hub" +    docker push pythondiscord/bot-base:latest +else +    echo "base.Dockerfile was not changed, not building" +fi + +echo "Building image" +docker build -t pythondiscord/bot:latest -f docker/bot.Dockerfile . + +echo "Pushing image" +docker push pythondiscord/bot:latest + +#echo "Deploying container" +#curl -H "token: $AUTODEPLOY_TOKEN" $AUTODEPLOY_WEBHOOK  |