Update main.yml #15
This file contains hidden or 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 Pipeline for AI Model Testing and Docker Deployment | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: 3.9 | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| - name: Add project root to PYTHONPATH | |
| run: echo "PYTHONPATH=$PYTHONPATH:$(pwd)" >> $GITHUB_ENV | |
| - name: Run tests with coverage | |
| run: | | |
| coverage run -m pytest | |
| coverage xml -o coverage.xml | |
| - name: Upload test report | |
| uses: actions/upload-artifact@v3 | |
| with: | |
| name: pytest-report | |
| path: report.xml | |
| - name: Upload coverage report | |
| uses: actions/upload-artifact@v3 | |
| with: | |
| name: coverage-report | |
| path: coverage.xml | |
| - name: Log in to Docker Hub | |
| uses: docker/login-action@v2 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Build and push Docker image | |
| run: | | |
| docker build -t adiseshu132/ai-model-api:latest . | |
| docker push adiseshu132/ai-model-api:latest |