Skip to content

feat: add ci

feat: add ci #1

Workflow file for this run

name: Python CI/CD
on:
push:
branches: [ main, lab03 ]
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@v5
with:
python-version: '3.12'
cache: 'pip'
cache-dependency-path: 'app_python/requirements.txt'
- name: Install dependencies
run: |
cd app_python
pip install -r requirements.txt
- name: Run a linter
run: |
cd app_python
flake8 app.py
- name: Run tests
run: |
cd app_python
pytest tests/test_app.py
build:
runs-on: ubuntu-latest
needs: test
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ./app_python
push: true
tags: |
${{ secrets.DOCKER_USERNAME }}/fastapi-app:latest
${{ secrets.DOCKER_USERNAME }}/fastapi-app:$(date +%Y.%m.%d)