diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..2125666 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text=auto \ No newline at end of file diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml new file mode 100644 index 0000000..0ae4d62 --- /dev/null +++ b/.github/workflows/main.yaml @@ -0,0 +1,137 @@ +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: 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/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: 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 }} diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100644 index 0000000..d0d1113 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,5 @@ +npx lint-staged + +echo "" +echo "🚀 Running test build..." +npm run build diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..e6ef4f3 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..03d9549 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..1448a1e --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/ocenka-web.iml b/.idea/ocenka-web.iml new file mode 100644 index 0000000..24643cc --- /dev/null +++ b/.idea/ocenka-web.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/prettier.xml b/.idea/prettier.xml new file mode 100644 index 0000000..b0c1c68 --- /dev/null +++ b/.idea/prettier.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..f481e8f --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,128 @@ + + + + + + + + + + + + + + + + + + + + { + "customColor": "", + "associatedIndex": 4 +} + + + + + + + + + + + + + + + + + + + + +