Feedback #24
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: Python application CI/CD | |
on: [push, pull_request] | |
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.12' # Choose the Python version you need | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
- name: Run tests | |
run: | | |
python -m pytest tests | |
deploy: | |
needs: build-and-test | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/main' # This ensures that deployment only happens on the main branch. | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Docker Environment | |
run: | | |
docker-compose build | |
docker-compose up -d | |