-
Notifications
You must be signed in to change notification settings - Fork 0
100 lines (91 loc) · 3.26 KB
/
build-deploy.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
100
name: CI/CD
on: [push, pull_request]
jobs:
build:
environment:
name: test
env:
DB_HOST: ${{secrets.DB_HOST}}
DB_PORT: ${{vars.DB_PORT}}
DB_PASSWORD: ${{secrets.DB_PASSWORD}}
DB_DATABASE: ${{vars.DB_DATABASE}}
DB_DATABASE_TESTING: ${{vars.DB_DATABASE_TESTING}}
DB_USER: ${{vars.DB_USER}}
AUTH_SECRET_KEY: ${{secrets.AUTH_SECRET_KEY}}
AUTH_ALGORITHM: ${{secrets.AUTH_ALGORITHM}}
ACCESS_TOKEN_EXPIRE_MINUTES: ${{vars.ACCESS_TOKEN_EXPIRE_MINUTES}}
SYMPTOM_SERVICE_URL: ${{vars.SYMPTOM_SERVICE_URL}}
MAIL_SERVICE_URL: ${{secrets.MAIL_SERVICE_URL}}
MAIL_SERVICE_API_KEY: ${{secrets.MAIL_SERVICE_API_KEY}}
API_URL: ${{secrets.API_URL}}
services:
postgres:
image: postgres
env:
POSTGRES_USER: ${{vars.DB_USER}}
POSTGRES_PASSWORD: ${{secrets.DB_PASSWORD}}
POSTGRES_DB: ${{secrets.DB_DATABASE_TESTING}}
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
runs-on: ubuntu-latest
steps:
- name: initialize github actions
uses: actions/checkout@v2
- name: install python
uses: actions/setup-python@v2
with:
python-version: "3.10"
- name: update pip
run: python -m pip install --upgrade pip
- name: install dependencies
run: pip install -r requirements.txt
- name: test
run: |
pip install pytest
pytest
deploy:
needs: [ build ]
environment:
name: prod
env:
DB_HOST: ${{secrets.DB_HOST}}
DB_PORT: ${{secrets.DB_PORT}}
DB_PASSWORD: ${{secrets.DB_PASSWORD}}
DB_DATABASE: ${{secrets.DB_DATABASE}}
DB_DATABASE_TESTING: ${{secrets.DB_DATABASE_TESTING}}
DB_USER: ${{secrets.DB_USER}}
AUTH_SECRET_KEY: ${{secrets.AUTH_SECRET_KEY}}
AUTH_ALGORITHM: ${{secrets.AUTH_ALGORITHM}}
ACCESS_TOKEN_EXPIRE_MINUTES: ${{secrets.ACCESS_TOKEN_EXPIRE_MINUTES}}
MAIL_SERVICE_URL: ${{secrets.MAIL_SERVICE_URL}}
MAIL_SERVICE_API_KEY: ${{secrets.MAIL_SERVICE_API_KEY}}
API_URL: ${{secrets.API_URL}}
SYMPTOM_SERVICE_URL: ${{secrets.SYMPTOM_SERVICE_URL}}
runs-on: ubuntu-latest
permissions:
id-token: write #This is required for requesting the OIDC JWT Token
steps:
- name: Checkout to the branch
uses: actions/checkout@v2
- name: Azure Login
uses: azure/login@v1
with:
client-id: ${{ secrets.HEALTHMATEAPI_AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.HEALTHMATEAPI_AZURE_TENANT_ID }}
subscription-id: ${{ secrets.HEALTHMATEAPI_AZURE_SUBSCRIPTION_ID }}
- name: Build and push container image to registry
uses: azure/container-apps-deploy-action@v1
with:
appSourcePath: ${{ github.workspace }}
registryUrl: jtmarilao.azurecr.io
registryUsername: ${{ secrets.HEALTHMATEAPI_REGISTRY_USERNAME }}
registryPassword: ${{ secrets.HEALTHMATEAPI_REGISTRY_PASSWORD }}
containerAppName: healthmate-api
resourceGroup: capstone
imageToBuild: jtmarilao.azurecr.io/healthmate-api:latest
dockerfilePath: Dockerfile