-
Notifications
You must be signed in to change notification settings - Fork 3
100 lines (82 loc) · 2.7 KB
/
main_vax-availability-api.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# More GitHub Actions for Azure: https://github.com/Azure/actions
name: Build and deploy vax-availability-api
on:
push:
branches:
- main
- staging
workflow_dispatch:
jobs:
BuildAndTest:
runs-on: 'ubuntu-latest'
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Install Python
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install Poetry
uses: abatilo/[email protected]
with:
poetry-version: 1.1.6
- name: Install dependencies
run: poetry install
- name: Run linters (mypy, black, isort)
run: |
poetry run mypy --config-file mypy.ini .
poetry run black --line-length 79 --check .
poetry run isort --profile black --line-length 79 --multi-line 3 \
--filter-files --check --diff .
BuildDocker:
runs-on: 'ubuntu-latest'
needs: BuildAndTest
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Set up Docker Build
uses: docker/setup-buildx-action@v1
- name: Log in to registry
uses: docker/login-action@v1
with:
registry: https://index.docker.io/v1/
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push container image to registry
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ secrets.DOCKER_USERNAME }}/vax-hunters-api:${{ github.sha }}
file: ./Dockerfile
DeployStaging:
runs-on: ubuntu-latest
needs: BuildDocker
environment:
name: 'staging'
url: ${{ steps.deploy-to-webapp-staging.outputs.webapp-url }}
steps:
- name: Deploy to Azure Web App (staging)
id: deploy-to-webapp-staging
uses: azure/webapps-deploy@v2
with:
app-name: 'vax-availability-api-staging'
slot-name: 'production'
publish-profile: ${{ secrets.AZURE_APP_SERVICE_PUBLISH_PROFILE }}
images: 'index.docker.io/${{ secrets.DOCKER_USERNAME }}/vax-hunters-api:${{ github.sha }}'
DeployProduction:
runs-on: ubuntu-latest
needs: DeployStaging
environment:
name: 'production'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
steps:
- name: Deploy to Azure Web App (production)
id: deploy-to-webapp
uses: azure/webapps-deploy@v2
with:
app-name: 'vax-availability-api'
slot-name: 'production'
publish-profile: ${{ secrets.AZURE_APP_SERVICE_PUBLISH_PROFILE }}
images: 'index.docker.io/${{ secrets.DOCKER_USERNAME }}/vax-hunters-api:${{ github.sha }}'