Update app.py #21
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 | |
on: [push, pull_request] | |
jobs: | |
build-and-test: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ["3.12"] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v3 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Cache dependencies | |
uses: actions/cache@v3 | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
- name: Install dependencies | |
run: make install | |
docker-build: | |
needs: build-and-test | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/main' | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Install Docker Compose | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y docker-compose | |
- name: Build Docker images | |
timeout-minutes: 5 | |
env: | |
AT_USERNAME: ${{ secrets.AT_USERNAME }} | |
AT_API_KEY: ${{ secrets.AT_API_KEY }} | |
run: | | |
make docker_run | |
- name: Check build status | |
run: | | |
if [ "$(docker ps -q)" ]; then | |
echo "Containers running successfully" | |
else | |
echo "No containers running" | |
exit 1 | |
fi | |
- name: Cleanup Docker resources | |
if: always() | |
timeout-minutes: 5 | |
run: | | |
docker-compose down --remove-orphans --timeout 30 | |
docker system prune -af --volumes |