test build and deploy
Some checks failed
CI/CD / test-backend (pull_request) Successful in 7s
CI/CD / test-frontend (pull_request) Successful in 9s
CI/CD / build-and-deploy (pull_request) Failing after 2m38s
CI/CD Pipeline / Overall Status ✅ Все проверки прошли успешно
CI/CD / pr-status (pull_request) Successful in 1s
Some checks failed
CI/CD / test-backend (pull_request) Successful in 7s
CI/CD / test-frontend (pull_request) Successful in 9s
CI/CD / build-and-deploy (pull_request) Failing after 2m38s
CI/CD Pipeline / Overall Status ✅ Все проверки прошли успешно
CI/CD / pr-status (pull_request) Successful in 1s
This commit is contained in:
@@ -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]
|
||||||
|
|||||||
Reference in New Issue
Block a user