CI/CD #13
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 | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.8' | |
- name: Install Dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
pip install -r dev-requirements.txt | |
pip install "black[jupyter]" # Install Jupyter support for Black | |
- name: Run Black | |
run: | | |
black . --exclude "\.ipynb$" # Skip Jupyter notebook files | |
- name: Run isort | |
run: | | |
isort --check-only . | |
- name: Run Pylint | |
run: | | |
pylint src tests | |
- name: Run Unit Tests | |
run: | | |
pytest --cov=src tests/ | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Build and Push Docker Image | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
file: deployment/Dockerfile # Use the correct path to Dockerfile | |
tags: user/repository:latest | |
push: true | |
deploy: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Deploy to Kubernetes | |
uses: azure/k8s-deploy@v1 | |
with: | |
manifests: | | |
deployment/kubernetes/deployment.yml | |
deployment/kubernetes/service.yml |