57 lines
1.2 KiB
YAML
57 lines
1.2 KiB
YAML
name: CI/CD Pipeline
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v4
|
|
with:
|
|
python-version: "3.11"
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
pip install -r requirements.txt
|
|
|
|
- name: Run tests
|
|
run: |
|
|
python -m pytest tests/ -v
|
|
|
|
- name: Run linting
|
|
run: |
|
|
python -m flake8 web/ tests/ --max-line-length=120
|
|
|
|
- name: Build Docker image
|
|
run: |
|
|
docker build -t jobs-app .
|
|
|
|
- name: Run container tests
|
|
run: |
|
|
docker run --rm jobs-app python -m pytest tests/ -v
|
|
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
needs: test
|
|
if: github.ref == 'refs/heads/main'
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Deploy to production
|
|
run: |
|
|
echo "Deploying to production..."
|
|
# Add your deployment commands here
|
|
# For example: docker-compose up -d
|