aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/deploy-azure.sh
blob: 8cb9fe770188e8b6590cc9070f1e0a43a5a2a80b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash

# Build and deploy on master branch, only if not a pull request
if [[ ($BUILD_SOURCEBRANCHNAME == 'master') && ($SYSTEM_PULLREQUEST_PULLREQUESTID == '') ]]; then
    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: $1" $2
else
    echo "Skipping deploy"
fi