This repository has been archived by the owner on Jan 30, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines.yml
57 lines (49 loc) · 1.73 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
pool:
vmImage: ubuntu-16.04
variables:
- group: 'AWS Credentials'
- name: pythonVersion
value: '3.7'
- name: imageName
value: 'drisk/mock-api-gateway'
- name: awsEcr
value: '268927183565.dkr.ecr.ap-southeast-1.amazonaws.com'
- name: awsImage
value: '$(awsEcr)/$(imageName)'
pr:
- master
steps:
- task: UsePythonVersion@0
inputs:
architecture: x64
versionSpec: $(pythonVersion)
- bash: |
python -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip setuptools
pip install -r requirements.freeze.txt
pip install --upgrade unittest-xml-reporting
displayName: 'Setup virtual environment'
- bash: |
source .venv/bin/activate
python manage.py test --testrunner xmlrunner.extra.djangotestrunner.XMLTestRunner --no-input
displayName: 'Run tests for Python $(pythonVersion)'
- task: PublishTestResults@2
inputs:
testRunTitle: 'Test results for Python $(pythonVersion)'
testResultsFiles: '**/TEST-*.xml'
condition: succeededOrFailed()
- bash: docker build . --tag $(awsImage):latest --tag $(awsImage):$(Build.BuildId)
displayName: 'Build Docker image'
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
- bash: |
pip install --upgrade awscli
$(aws ecr get-login --no-include-email)
aws ecr create-repository --repository-name $(imageName)
docker push $(awsImage)
displayName: 'Push Docker image to AWS ECR'
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
env:
AWS_ACCESS_KEY_ID: $(AWS_ACCESS_KEY_ID)
AWS_DEFAULT_REGION: $(AWS_DEFAULT_REGION)
AWS_SECRET_ACCESS_KEY: $(AWS_SECRET_ACCESS_KEY)