-
Notifications
You must be signed in to change notification settings - Fork 2
79 lines (64 loc) · 2.31 KB
/
Copy pathCD.yml
File metadata and controls
79 lines (64 loc) · 2.31 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
name: CD
on:
push:
branches:
- main
workflow_dispatch:
jobs:
lint-test-build-deploy:
runs-on: ubuntu-latest
env:
REPO_ROOT: ${{ github.workspace }}
steps:
- name: Checkout Repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r tests/requirements_CI-CD.txt
- name: Configure DVC S3 remote
run: |
dvc remote modify origin endpointurl https://dagshub.com/schytze0/deep_leaf.s3
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- name: Pull the production model and train.tfrecord file
run: |
dvc pull models/production_model.keras
dvc pull data/training/train.tfrecord
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- name: Run flake8
run: |
flake8 --exclude=.env,.github --max-line-length=120 .
continue-on-error: true
- name: Run tests with pytest
run: |
pytest --maxfail=1 --disable-warnings -v
- name: Build Docker image with docker-compose (only fastapi service)
run: |
docker compose build fastapi-app
- name: Launch fastapi container
run: |
docker compose up -d fastapi-app
sleep 10 # wait 10 seconds for container to start
# - name: Check API health
# run: |
# curl --fail http://localhost:8001/ || (echo "API not responding" && exit 1)
- name: Stop container
if: always()
run: docker compose down
- name: Docker login
run: |
echo "${{ secrets.DOCKERHUB_PASSWORD }}" | docker login --username "${{ secrets.DOCKERHUB_USERNAME }}" --password-stdin
- name: Tag & push fastapi image to DockerHub
run: |
docker tag fastapi-app:latest ${{ secrets.DOCKERHUB_USERNAME }}/deepleaf-fastapi-app:latest
docker push ${{ secrets.DOCKERHUB_USERNAME }}/deepleaf-fastapi-app:latest