From 55a48eb6f973af52b834a214f96e1c32371c28da Mon Sep 17 00:00:00 2001 From: RedrockJS Date: Fri, 19 Dec 2025 14:02:02 +0300 Subject: [PATCH] fix(ci): update deploy workflows --- .gitea/workflows/main.yaml | 134 ++++++++++++++++++ .../{main.yaml => main.yaml-disable} | 0 2 files changed, 134 insertions(+) create mode 100644 .gitea/workflows/main.yaml rename .github/workflows/{main.yaml => main.yaml-disable} (100%) diff --git a/.gitea/workflows/main.yaml b/.gitea/workflows/main.yaml new file mode 100644 index 0000000..c2941f5 --- /dev/null +++ b/.gitea/workflows/main.yaml @@ -0,0 +1,134 @@ +name: Build and deploy + +on: + push: + branches: + - 'main' + +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: 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: Build and push + uses: docker/build-push-action@v5 + with: + push: true + tags: smallbuster/ocenka-web: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: ubuntu-latest + 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 }} diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml-disable similarity index 100% rename from .github/workflows/main.yaml rename to .github/workflows/main.yaml-disable