fixing ci-cd #7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | |
- name: Install dependencies | |
run: | | |
pip install -r requirements.txt | |
pip install pytest # or any other needed testing libraries | |
- name: Run unit tests | |
run: 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 }} | |
- 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: Notify Deployment | |
run: echo "Images built and pushed successfully!" |