This repository has been archived by the owner on Jul 16, 2022. It is now read-only.
forked from BrewBlox/brewblox-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 3
/
azure-pipelines.yml
73 lines (61 loc) · 1.8 KB
/
azure-pipelines.yml
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
pool:
vmImage: 'Ubuntu-20.04'
trigger:
tags:
include:
- "*"
branches:
include:
- refs/heads/*
pr:
branches:
include:
- '*'
variables:
# Variables imported from brewblox group:
# DOCKER_USER
# DOCKER_PASSWORD
- group: brewblox
steps:
- task: UsePythonVersion@0
inputs:
addToPath: true
versionSpec: '3.7'
architecture: 'x64'
- bash: |
set -o allexport; source .env; set +o allexport
echo "##vso[task.setvariable variable=DOCKER_REPO]$DOCKER_REPO"
displayName: Export .env variables
- bash: |
BRANCH=$(echo $(Build.SourceBranch) | grep -oP "^refs/heads/\K.*")
TAG=$(echo $BRANCH | tr '/' '-' | tr '[:upper:]' '[:lower:]')
echo "##vso[task.setvariable variable=BRANCH]$BRANCH"
echo "##vso[task.setvariable variable=TAG]$TAG"
displayName: Export build variables
- bash: |
pip install poetry
poetry install
displayName: Install dependencies
- bash: poetry run pytest
displayName: Run Pytest
- bash: |
curl -fsSL https://raw.githubusercontent.com/BrewBlox/deployed-images/develop/prepare_buildx.sh | bash
displayName: Prepare buildx
condition: and(succeeded(), variables.BRANCH)
- bash: echo $(DOCKER_PASSWORD) | docker login -u $(DOCKER_USER) --password-stdin
displayName: Docker login
condition: and(succeeded(), variables.BRANCH)
- bash: bash ./before_build.sh
displayName: Run before_build.sh script
workingDirectory: docker
condition: and(succeeded(), variables.BRANCH)
- bash: >-
docker buildx build
--tag $(DOCKER_REPO):$(TAG)
--tag $(DOCKER_REPO):rpi-$(TAG)
--build-arg service_info="$(git describe) @ $(date)"
--push
--platform linux/amd64,linux/arm/v7,linux/arm64/v8
docker
displayName: Deploy Docker images with branch tags
condition: and(succeeded(), variables['BRANCH'])