-
Notifications
You must be signed in to change notification settings - Fork 0
63 lines (51 loc) · 1.63 KB
/
Copy pathdeploy.yml
File metadata and controls
63 lines (51 loc) · 1.63 KB
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
name: Build and Deploy to Azure
on:
push:
branches: [main]
pull_request:
branches: [main]
env:
DOCKER_IMAGE: fraud-detection
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
pip install -r requirements.txt
- name: Run tests
run: pytest tests/unit/test_core_logic.py -v
build-and-deploy:
runs-on: ubuntu-latest
needs: test
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
steps:
- uses: actions/checkout@v4
- name: Login to ACR
uses: docker/login-action@v3
with:
registry: ${{ secrets.ACR_LOGIN_SERVER }}
username: ${{ secrets.ACR_USERNAME }}
password: ${{ secrets.ACR_PASSWORD }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: |
${{ secrets.ACR_LOGIN_SERVER }}/${{ env.DOCKER_IMAGE }}:${{ github.sha }}
${{ secrets.ACR_LOGIN_SERVER }}/${{ env.DOCKER_IMAGE }}:latest
- name: Login to Azure
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Deploy to Azure Web App
uses: azure/webapps-deploy@v2
with:
app-name: ${{ secrets.AZURE_WEBAPP_NAME }}
images: ${{ secrets.ACR_LOGIN_SERVER }}/${{ env.DOCKER_IMAGE }}:${{ github.sha }}