From f8fb64ea8286cc1f3b14673fa1a652bd0e9e748b Mon Sep 17 00:00:00 2001 From: Stanislav Khoshov Date: Sat, 6 Sep 2025 18:23:26 +0300 Subject: [PATCH] update deploy script --- .github/workflows/deploy_dev.yml | 98 ++++++++++++++++---------------- .gitignore | 4 +- frontend/src/lib/api.ts | 41 +++++++++++++ frontend/src/lib/utils.ts | 6 ++ 4 files changed, 98 insertions(+), 51 deletions(-) create mode 100644 frontend/src/lib/api.ts create mode 100644 frontend/src/lib/utils.ts diff --git a/.github/workflows/deploy_dev.yml b/.github/workflows/deploy_dev.yml index 223df54..2dd7eb2 100644 --- a/.github/workflows/deploy_dev.yml +++ b/.github/workflows/deploy_dev.yml @@ -10,53 +10,53 @@ jobs: runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Setup Node - uses: actions/setup-node@v4 - with: - node-version: 20 - cache: 'npm' - cache-dependency-path: frontend/package-lock.json - - - name: Install deps (frontend) - working-directory: frontend - run: npm ci - - - name: Debug TypeScript config and paths - working-directory: frontend - run: | - npx tsc -p tsconfig.json --showConfig | sed -n '1,200p' - ls -la src/lib || true - grep -R --line-number --color=never "from '@/lib" src || true - - - name: Build frontend - working-directory: frontend - run: npm run build - - - name: Copy files to server - uses: appleboy/scp-action@v0.1.7 - with: - host: ${{ secrets.DEV_SERVER_HOST }} - username: ${{ secrets.DEV_SSH_USERNAME }} - key: ${{ secrets.DEV_SSH_PRIVATE_KEY }} - source: "frontend/dist/*" - target: "${{ secrets.DEV_PROJECT_PATH }}/frontend/dist/" - - - name: Deploy - uses: appleboy/ssh-action@v1.0.0 - with: - host: ${{ secrets.DEV_SERVER_HOST }} - username: ${{ secrets.DEV_SSH_USERNAME }} - key: ${{ secrets.DEV_SSH_PRIVATE_KEY }} - script: | - cd ${{ secrets.DEV_PROJECT_PATH }} - git pull origin develop + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'npm' + cache-dependency-path: frontend/package-lock.json + + - name: Install deps (frontend) + working-directory: frontend + run: npm ci + + - name: Debug TypeScript config and paths + working-directory: frontend + run: | + npx tsc -p tsconfig.json --showConfig | sed -n '1,200p' + ls -la src/lib || true + grep -R --line-number --color=never "from '@/lib" src || true + + - name: Build frontend + working-directory: frontend + run: npm run build + + - name: Copy files to server + uses: appleboy/scp-action@v0.1.7 + with: + host: ${{ secrets.DEV_SERVER_HOST }} + username: ${{ secrets.DEV_SSH_USERNAME }} + key: ${{ secrets.DEV_SSH_PRIVATE_KEY }} + source: "frontend/dist/*" + target: "${{ secrets.DEV_PROJECT_PATH }}/frontend/dist/" + + - name: Deploy + uses: appleboy/ssh-action@v1.0.0 + with: + host: ${{ secrets.DEV_SERVER_HOST }} + username: ${{ secrets.DEV_SSH_USERNAME }} + key: ${{ secrets.DEV_SSH_PRIVATE_KEY }} + script: | + cd ${{ secrets.DEV_PROJECT_PATH }} + git pull origin develop - uv sync --no-dev - uv run manage.py migrate - - sudo systemctl restart pythonbooks - - echo "Deployment successful!" + uv sync --no-dev + uv run manage.py migrate + + sudo systemctl restart pythonbooks + + echo "Deployment successful!" diff --git a/.gitignore b/.gitignore index 5f9a035..41a51d6 100644 --- a/.gitignore +++ b/.gitignore @@ -48,8 +48,8 @@ dist/ downloads/ eggs/ .eggs/ -lib/ -lib64/ +#lib/ +#lib64/ parts/ sdist/ var/ diff --git a/frontend/src/lib/api.ts b/frontend/src/lib/api.ts new file mode 100644 index 0000000..7777cc9 --- /dev/null +++ b/frontend/src/lib/api.ts @@ -0,0 +1,41 @@ +import axios from 'axios'; +import type { Book, Publisher, Tag, PaginatedResponse } from '@/types'; + +const API_BASE_URL = 'http://localhost:8001/api/v1'; + +const api = axios.create({ + baseURL: API_BASE_URL, + headers: { + 'Content-Type': 'application/json', + }, +}); + +export const booksApi = { + getBooks: async (params?: { + search?: string; + category?: string; + publisher?: string; + sort?: string; + page?: number; + }): Promise> => { + const response = await api.get('/books/', { params }); + return response.data; + }, + + getBook: async (id: number): Promise => { + const response = await api.get(`/books/${id}/`); + return response.data; + }, + + getPublishers: async (): Promise => { + const response = await api.get('/publishers/'); + return response.data.results || response.data; + }, + + getTags: async (): Promise => { + const response = await api.get('/tags/'); + return response.data.results || response.data; + }, +}; + +export default api; \ No newline at end of file diff --git a/frontend/src/lib/utils.ts b/frontend/src/lib/utils.ts new file mode 100644 index 0000000..04b43bf --- /dev/null +++ b/frontend/src/lib/utils.ts @@ -0,0 +1,6 @@ +import { type ClassValue, clsx } from "clsx" +import { twMerge } from "tailwind-merge" + +export function cn(...inputs: ClassValue[]) { + return twMerge(clsx(inputs)) +} \ No newline at end of file