diff options
author | 2018-11-18 00:34:44 +0100 | |
---|---|---|
committer | 2018-11-18 00:34:44 +0100 | |
commit | f4c659b5260c9d17b69104047d25adeef1840ca4 (patch) | |
tree | 9744f22b5674ae7eb9360006a140740d95588a2f | |
parent | Update README.md (diff) |
Azure Pipeline CI
-rw-r--r-- | .travis.yml | 17 | ||||
-rw-r--r-- | azure-pipelines.yml | 65 | ||||
-rwxr-xr-x | docker/build.sh | 18 | ||||
-rw-r--r-- | docker/docker-compose.yml | 4 | ||||
-rwxr-xr-x | scripts/deploy-azure.sh | 17 |
5 files changed, 84 insertions, 37 deletions
diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index ae1d7653..00000000 --- a/.travis.yml +++ /dev/null @@ -1,17 +0,0 @@ -language: python - -python: - - "3.7-dev" - -sudo: required - -services: - - docker - -install: - - pip install flake8 pipenv salt-pepper - - pipenv install --deploy - -script: - - pipenv run lint - - bash docker/build.sh diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 00000000..772655ac --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,65 @@ +# https://aka.ms/yaml + +variables: + ENV LIBRARY_PATH: /lib:/usr/lib + ENV PIPENV_HIDE_EMOJIS: 1 + ENV PIPENV_IGNORE_VIRTUALENVS: 1 + ENV PIPENV_NOSPIN: 1 + ENV PIPENV_VENV_IN_PROJECT: 1 + ENV SALTAPI_EAUTH: pam + ENV SALTAPI_PASS: $(SALTAPI_PASS) + ENV SALTAPI_URL: $(SALTAPI_URL) + ENV SALTAPI_USER: $(SALTAPI_USER) + +jobs: +- job: test + displayName: 'Lint & Test' + + pool: + vmImage: 'Ubuntu 16.04' + + variables: + PIPENV_CACHE_DIR: ".cache/pipenv" + PIP_CACHE_DIR: ".cache/pip" + + steps: + - script: sudo apt-get install build-essential curl docker libffi-dev libfreetype6-dev libxml2 libxml2-dev libxslt1-dev zlib1g zlib1g-dev + displayName: 'Install base dependencies' + + - task: UsePythonVersion@0 + displayName: 'Set Python version' + inputs: + versionSpec: '3.7.x' + addToPath: true + + - script: sudo pip install pipenv + displayName: 'Install pipenv' + + - script: sudo pip install salt-pepper + displayName: 'Install saltstack' + + - script: pipenv install --dev --deploy --system + displayName: 'Install project using pipenv' + + - script: python -m flake8 + displayName: 'Run linter' + +- job: build + displayName: 'Build Containers' + dependsOn: 'test' + + steps: + - task: Docker@1 + displayName: 'Login: Docker Hub' + + inputs: + containerregistrytype: 'Container Registry' + dockerRegistryEndpoint: 'DockerHub' + command: 'login' + + - task: ShellScript@2 + displayName: 'Build and deploy containers' + + inputs: + scriptPath: scripts/deploy-azure.sh + args: '$(SALTAPI_TARGET)' diff --git a/docker/build.sh b/docker/build.sh deleted file mode 100755 index 153fbccc..00000000 --- a/docker/build.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -# Build and deploy on master branch -if [[ $TRAVIS_BRANCH == 'master' && $TRAVIS_PULL_REQUEST == 'false' ]]; then - echo "Connecting to docker hub" - echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin - - echo "Building image" - docker build -t pythondiscord/hacktober-bot:latest -f docker/Dockerfile . - - echo "Pushing image" - docker push pythondiscord/hacktober-bot:latest - - echo "Deploying on server" - pepper ${SALTAPI_TARGET} state.apply docker/hacktoberbot --out=no_out --non-interactive &> /dev/null -else - echo "Skipping deploy" -fi diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 0a802ddc..1c895456 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -1,8 +1,8 @@ version: "3" services: dumbo: - image: pythondiscord/hacktober-bot:latest - container_name: hacktoberbot + image: pythondiscord/seasonalbot:latest + container_name: seasonalbot restart: always diff --git a/scripts/deploy-azure.sh b/scripts/deploy-azure.sh new file mode 100755 index 00000000..c11b6afa --- /dev/null +++ b/scripts/deploy-azure.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +cd .. + +# Build and deploy on master branch, only if not a pull request +if [[ ($BUILD_SOURCEBRANCHNAME == 'master') && ($SYSTEM_PULLREQUEST_PULLREQUESTID == '') ]]; then + echo "Building image" + docker build -t pythondiscord/seasonalbot:latest -f docker/Dockerfile . + + echo "Pushing image to Docker Hub" + docker push pythondiscord/seasonalbot:latest + + echo "Deploying on server" + pepper $1 state.apply docker/hacktoberbot --out=no_out --non-interactive &> /dev/null +else + echo "Skipping deploy" +fi |