test build and deploy #10

Open
RaiLinKey wants to merge 10 commits from fix into test
Showing only changes of commit c185b62441 - Show all commits

View File

@@ -54,6 +54,68 @@ jobs:
cd web cd web
npm run build npm run build
build-and-deploy:
needs: test-backend
runs-on: ubuntu-latest
if: success() # Запускается только если тесты прошли успешно
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to container registry
uses: docker/login-action@v3
with:
registry: gitea.example.com # Замените на ваш Gitea registry
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_TOKEN }}
- name: Build Docker image
id: build
uses: docker/build-push-action@v5
with:
context: .
push: false
load: true
tags: fastapi-app:latest
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Stop and remove old container
run: |
docker stop fastapi-container || true
docker rm fastapi-container || true
- name: Run new container
run: |
docker run -d \
--name fastapi-container \
-p 8080:8000 \
--restart unless-stopped \
fastapi-app:latest
- name: Wait for container to be ready
run: |
for i in {1..30}; do
if curl -s http://localhost:8080/health > /dev/null; then
echo "Container is ready!"
exit 0
fi
echo "Waiting for container... ($i/30)"
sleep 2
done
echo "Container failed to start properly"
docker logs fastapi-container
exit 1
- name: Verify deployment
run: |
curl -f http://localhost:8080/ || exit 1
echo "Deployment successful!"
# Явный статус для PR # Явный статус для PR
pr-status: pr-status:
needs: [test-backend, test-frontend] needs: [test-backend, test-frontend]