generated from nyu-software-engineering/final-project
-
Notifications
You must be signed in to change notification settings - Fork 2
86 lines (71 loc) · 2.2 KB
/
ci-cd.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
name: CI/CD Pipeline
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build-and-test:
runs-on: ubuntu-latest
services:
mongodb:
image: mongo
ports:
- 27017:27017
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.8'
# Install dependencies for the Machine Learning Client
- name: Install dependencies for ML client
run: |
cd machine-learning-client
pip install -r requirements.txt
# Run unit tests for ML client
- name: Run unit tests for ML client
run: |
cd machine-learning-client
pytest
# Install dependencies for the Web App
- name: Install dependencies for Web App
run: |
cd web-app
pip install -r requirements.txt
# Run unit tests for Web App
# - name: Run unit tests for Web App
# run: |
# cd web-app
# pytest
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Log in to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }}
# Build and push Docker images for each subsystem
- name: Build and push machine learning client Docker image
uses: docker/build-push-action@v2
with:
context: ./machine-learning-client
file: ./machine-learning-client/Dockerfile
push: true
tags: kondalex/machine-learning-client:latest
- name: Build and push web app Docker image
uses: docker/build-push-action@v2
with:
context: ./web-app
file: ./web-app/Dockerfile
push: true
tags: kondalex/web-app:latest
- name: Deploy Docker images
run: |
docker pull kondalex/machine-learning-client:latest
docker pull kondalex/web-app:latest
docker-compose -f docker-compose.yml up -d
- name: Notify Deployment
run: echo "Images built, pushed, and deployed successfully!"