From c9d88e43c71f4d0e5e884350c9eb5a7ba6da9492 Mon Sep 17 00:00:00 2001 From: RedrockJS Date: Fri, 19 Dec 2025 13:47:48 +0300 Subject: [PATCH] fix(ci): update deploy workflows --- {.github => .gitea}/workflows/main.yaml | 9 +- .github/workflows/main.yaml-disable | 140 ++++++++++++++++++++++++ 2 files changed, 143 insertions(+), 6 deletions(-) rename {.github => .gitea}/workflows/main.yaml (96%) create mode 100644 .github/workflows/main.yaml-disable diff --git a/.github/workflows/main.yaml b/.gitea/workflows/main.yaml similarity index 96% rename from .github/workflows/main.yaml rename to .gitea/workflows/main.yaml index 98a53ce..968e5a0 100644 --- a/.github/workflows/main.yaml +++ b/.gitea/workflows/main.yaml @@ -19,11 +19,8 @@ jobs: Сервер: ${{ secrets.SERVER_NAME }} Репозиторий: ${{ github.repository }} - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 + - name: Checkout repository + uses: actions/checkout@v4 - name: Login to Docker Hub uses: docker/login-action@v3 @@ -71,7 +68,7 @@ jobs: Подробности: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} deploy: - runs-on: self-hosted + runs-on: ubuntu-latest needs: build steps: - name: Notify Telegram start deploy diff --git a/.github/workflows/main.yaml-disable b/.github/workflows/main.yaml-disable new file mode 100644 index 0000000..ac4fec0 --- /dev/null +++ b/.github/workflows/main.yaml-disable @@ -0,0 +1,140 @@ +name: Build and deploy + +on: + push: + branches: + - 'main' + +# Условие, чтобы остановить выполнение +if: false + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Notify Telegram start building + uses: appleboy/telegram-action@master + with: + to: ${{ secrets.TELEGRAM_CHAT_ID }} + token: ${{ secrets.TELEGRAM_BOT_TOKEN }} + message: | + 🚀 Запуск сборки! + Сервер: ${{ secrets.SERVER_NAME }} + Репозиторий: ${{ github.repository }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v5 + with: + push: true + tags: smallbuster/fire-exam:latest + build-args: | + NEXT_PUBLIC_MAIL_USER=${{ secrets.NEXT_PUBLIC_MAIL_USER }} + NEXT_PUBLIC_MAIL_PASS=${{ secrets.NEXT_PUBLIC_MAIL_PASS }} + NEXT_PUBLIC_MAIL_FROM=${{ secrets.NEXT_PUBLIC_MAIL_FROM }} + NEXT_PUBLIC_MAIL_TO=${{ secrets.NEXT_PUBLIC_MAIL_TO }} + NEXT_PUBLIC_MAIL_SECURE_KEY=${{ secrets.NEXT_PUBLIC_MAIL_SECURE_KEY }} + + - name: Notify Telegram about success + if: success() + uses: appleboy/telegram-action@master + with: + to: ${{ secrets.TELEGRAM_CHAT_ID }} + token: ${{ secrets.TELEGRAM_BOT_TOKEN }} + message: | + ✅ Сборка успешно завершена! + Сервер: ${{ secrets.SERVER_NAME }} + Репозиторий: ${{ github.repository }} + Ветка: ${{ github.ref_name }} + Коммит: ${{ github.sha }} + + - name: Notify Telegram about failure + if: failure() + uses: appleboy/telegram-action@master + with: + to: ${{ secrets.TELEGRAM_CHAT_ID }} + token: ${{ secrets.TELEGRAM_BOT_TOKEN }} + message: | + ❌ Сборка проекта неудачна! + Сервер: ${{ secrets.SERVER_NAME }} + Репозиторий: ${{ github.repository }} + Ветка: ${{ github.ref_name }} + Коммит: ${{ github.sha }} + Подробности: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + + deploy: + runs-on: self-hosted + needs: build + steps: + - name: Notify Telegram start deploy + uses: appleboy/telegram-action@master + with: + to: ${{ secrets.TELEGRAM_CHAT_ID }} + token: ${{ secrets.TELEGRAM_BOT_TOKEN }} + message: | + 🐳 Запуск деплоя! + Сервер: ${{ secrets.SERVER_NAME }} + Репозиторий: ${{ github.repository }} + + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Set up Docker Compose + run: | + docker compose version + + - name: Stop and remove existing containers + run: | + docker compose -f docker-compose.yaml down || true + + - name: Pull Docker images + run: | + docker compose -f docker-compose.yaml pull + + - name: Start containers + run: | + docker compose -f docker-compose.yaml up -d + + - name: Notify Telegram about success + if: success() + uses: appleboy/telegram-action@master + with: + to: ${{ secrets.TELEGRAM_CHAT_ID }} + token: ${{ secrets.TELEGRAM_BOT_TOKEN }} + message: | + ✅ Деплой успешно завершен! + Сервер: ${{ secrets.SERVER_NAME }} + Репозиторий: ${{ github.repository }} + Ветка: ${{ github.ref_name }} + Коммит: ${{ github.sha }} + + - name: Notify Telegram about failure + if: failure() + uses: appleboy/telegram-action@master + with: + to: ${{ secrets.TELEGRAM_CHAT_ID }} + token: ${{ secrets.TELEGRAM_BOT_TOKEN }} + message: | + ❌ Деплой не удался! + Сервер: ${{ secrets.SERVER_NAME }} + Репозиторий: ${{ github.repository }} + Ветка: ${{ github.ref_name }} + Коммит: ${{ github.sha }} + Подробности: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} -- 2.49.1