aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitlab-ci.yml10
-rw-r--r--azure-pipelines.yml54
-rw-r--r--bot/cogs/snekbox.py2
-rw-r--r--scripts/deploy-azure.sh29
4 files changed, 84 insertions, 11 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index f7aee8165..44126ded9 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -26,13 +26,3 @@ test:
- python -m flake8
- ls /root/.cache/
-build:
- tags:
- - docker
-
- services:
- - docker:dind
-
- stage: build
- script:
- - sh scripts/deploy.sh
diff --git a/azure-pipelines.yml b/azure-pipelines.yml
new file mode 100644
index 000000000..534742f4f
--- /dev/null
+++ b/azure-pipelines.yml
@@ -0,0 +1,54 @@
+# 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
+
+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: 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'
+
+ - bash: bash scripts/deploy-azure.sh
+ displayName: 'Build and deploy containers'
diff --git a/bot/cogs/snekbox.py b/bot/cogs/snekbox.py
index 184a7545d..1b51da843 100644
--- a/bot/cogs/snekbox.py
+++ b/bot/cogs/snekbox.py
@@ -184,7 +184,7 @@ class Snekbox:
msg = f"{ctx.author.mention} Your eval job has completed.\n\n```py\n{output}\n```"
response = await ctx.send(msg)
- await wait_for_deletion(response, user_ids=(ctx.author.id,), client=ctx.bot)
+ self.bot.loop.create_task(wait_for_deletion(response, user_ids=(ctx.author.id,), client=ctx.bot))
else:
await ctx.send(
diff --git a/scripts/deploy-azure.sh b/scripts/deploy-azure.sh
new file mode 100644
index 000000000..9f64b52a2
--- /dev/null
+++ b/scripts/deploy-azure.sh
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+# Build and deploy on master branch, only if not a pull request
+if [[ ($BUILD_SOURCEBRANCHNAME == 'master') && (-z '$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: $AUTODEPLOY_TOKEN" $AUTODEPLOY_WEBHOOK
+else
+ echo "Skipping deploy"
+fi \ No newline at end of file