-
Notifications
You must be signed in to change notification settings - Fork 1
62 lines (58 loc) · 1.8 KB
/
api-test-deploy-dev.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
name: 'API: tests & dev deploy'
on:
push:
branches-ignore:
- main
paths:
- 'api/**'
- 'Dockerfile'
- '.dockerignore'
- '.github/workflows/api-test-deploy-dev.yml'
env:
AZURE_ACR_NAME: sykeprtrdevacr.azurecr.io # set separately to jobs.tests.container.image
AZURE_WEBAPP_NAME: syke-prtr-fastapi-d-cont
jobs:
tests:
name: Test API
runs-on: ubuntu-latest
container:
image: sykeprtrdevacr.azurecr.io/fin-prtr:tests
credentials:
username: ${{ secrets.PROD_AZURE_CREDENTIALS_CLIENT_ID }}
password: ${{ secrets.PROD_AZURE_CREDENTIALS_CLIENT_SECRET }}
steps:
- uses: actions/checkout@v2
- name: Test PRTR API
run: |
cd api/
python -m pytest tests/ -vv
build-deploy-dev:
name: Build & deploy dev
if: github.ref == 'refs/heads/dev'
runs-on: ubuntu-latest
needs: tests
steps:
- uses: actions/checkout@v2
- uses: azure/docker-login@v1
with:
login-server: ${{ env.AZURE_ACR_NAME }}
username: ${{ secrets.PROD_AZURE_CREDENTIALS_CLIENT_ID }}
password: ${{ secrets.PROD_AZURE_CREDENTIALS_CLIENT_SECRET }}
- uses: azure/login@v1
with:
creds: ${{ secrets.DEV_AZURE_CREDENTIALS }}
- name: Build & push image
run: |
docker build . \
-t ${{ env.AZURE_ACR_NAME }}/fin-prtr:latest \
-t ${{ env.AZURE_ACR_NAME }}/fin-prtr:${{ github.sha }}
docker push ${{ env.AZURE_ACR_NAME }}/fin-prtr:latest
docker push ${{ env.AZURE_ACR_NAME }}/fin-prtr:${{ github.sha }}
- name: 'Deploy to Azure WebApp'
uses: azure/webapps-deploy@v2
with:
app-name: ${{ env.AZURE_WEBAPP_NAME }}
images: '${{ env.AZURE_ACR_NAME }}/fin-prtr:${{ github.sha }}'
- name: logout
run: |
az logout