From 6b4eb16733f9b067774f1efc4cc6557bd9a8e231 Mon Sep 17 00:00:00 2001 From: Mohammad Sajad Pourajam Date: Fri, 20 Mar 2026 23:40:52 +0330 Subject: [PATCH] CI/CD --- .gitea/workflows/frontend.yml | 88 +++++++++++++++ .github/workflows/frontend.yml | 72 +++++++++++++ Dockerfile | 3 + public/logo svg.svg | 147 ++++++++++++++++++++++++++ src/@core/svg/Logo.tsx | 31 +----- src/components/layout/shared/Logo.tsx | 6 +- src/configs/primaryColorConfig.ts | 19 +++- 7 files changed, 334 insertions(+), 32 deletions(-) create mode 100644 .gitea/workflows/frontend.yml create mode 100644 .github/workflows/frontend.yml create mode 100644 public/logo svg.svg diff --git a/.gitea/workflows/frontend.yml b/.gitea/workflows/frontend.yml new file mode 100644 index 0000000..a092d08 --- /dev/null +++ b/.gitea/workflows/frontend.yml @@ -0,0 +1,88 @@ +name: Frontend CI/CD + +on: + push: + branches: [main] + paths: + - 'frontend/**' + - '.gitea/workflows/frontend.yml' + + pull_request: + branches: [main] + paths: + - 'frontend/**' + - '.gitea/workflows/frontend.yml' + +jobs: + build-and-test: + name: Build, Lint & Test + runs-on: self-hosted + container: + image: mirror2.chabokan.net/ubuntu:22.04 + options: --add-host gitea:172.17.0.1 + + steps: + - name: Setup Ubuntu apt mirrors + run: | + tee /etc/apt/sources.list > /dev/null <<'EOF' + deb http://mirror.iranserver.com/ubuntu/ jammy main restricted universe multiverse + deb http://mirror.iranserver.com/ubuntu/ jammy-updates main restricted universe multiverse + deb http://mirror.iranserver.com/ubuntu/ jammy-security main restricted universe multiverse + deb http://mirror.iranserver.com/ubuntu/ jammy-backports main restricted universe multiverse + + deb [trusted=yes] https://mirror2.chabokan.net/ubuntu focal main universe + deb [trusted=yes] https://mirror2.chabokan.net/ubuntu focal-updates main universe + deb [trusted=yes] https://mirror2.chabokan.net/ubuntu focal-security main universe + EOF + apt-get update + + - name: Install system dependencies + run: | + apt-get install -y git nodejs npm build-essential + + - name: Checkout repository + run: | + git clone http://gitea:3000/sajad-dev/Frontend.git . + + - name: Configure NPM Mirrors + run: | + npm config set registry https://package-mirror.liara.ir/repository/npm/ + + npm config set @runflare:registry https://mirror-npm.runflare.com/ + npm config set @chabokan:registry https://mirror2.chabokan.net/npm/ + + npm config set strict-ssl false + npm config set fetch-retries 5 + npm config set fetch-retry-mintimeout 20000 + + - name: Install dependencies + run: | + cd frontend + npm install --registry=https://package-mirror.liara.ir/repository/npm/ + + - name: Build project + run: | + cd frontend + npm run build --if-present + + - name: Run Lint + run: | + cd frontend + npm run lint --if-present + + # - name: Setup SSH key + # run: | + # mkdir -p ~/.ssh + # echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_ed25519 + # chmod 600 ~/.ssh/id_ed25519 + # ssh-keyscan -p ${{secrets.SERVER_SSH_PORT}} -H ${{ secrets.SERVER_HOST }} >> ~/.ssh/known_hosts + + # - name: Deploy + # if: github.ref == 'refs/heads/main' + # run: | + # ssh ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_HOST }} -p ${{secrets.SERVER_SSH_PORT}} << 'EOF' + # cd /opt/myproject/frontend + # git pull origin main + # # در صورت استفاده از PM2 یا Systemd: + # sudo systemctl restart frontend + # EOF diff --git a/.github/workflows/frontend.yml b/.github/workflows/frontend.yml new file mode 100644 index 0000000..c7acf6b --- /dev/null +++ b/.github/workflows/frontend.yml @@ -0,0 +1,72 @@ + name: Frontend CI/CD + + on: + push: + branches: [main] + paths: + - 'frontend/**' + - 'frontend/.github/workflows/frontend.yml' + pull_request: + branches: [main] + paths: + - 'frontend/**' + - 'frontend/.github/workflows/frontend.yml' + + defaults: + run: + working-directory: frontend + + jobs: + build: + name: Build, Lint & Test + runs-on: ubuntu-latest + strategy: + fail-fast: true + matrix: + node-version: ['20'] + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + + - name: Cache npm dependencies + uses: actions/cache@v4 + with: + path: ~/.npm + key: ${{ runner.os }}-npm-frontend-${{ hashFiles('frontend/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-npm-frontend- + + - name: Install dependencies + run: npm ci + + - name: Build + run: npm run build + + - name: Lint + run: npm run lint --if-present + + - name: Test + run: npm test --if-present + + deploy: + name: Deploy Frontend + needs: build + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + runs-on: ubuntu-latest + steps: + - name: Deploy via SSH + uses: appleboy/ssh-action@v1 + with: + host: ${{ secrets.SSH_HOST }} + username: ${{ secrets.SSH_USER }} + port: ${{ secrets.SSH_PORT }} + key: ${{ secrets.SSH_PRIVATE_KEY }} + script: | + cd /opt/myproject/frontend + git pull origin main + sudo systemctl restart frontend diff --git a/Dockerfile b/Dockerfile index a34e331..fb90974 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,6 @@ # Stage 1: Dependencies FROM node:20-alpine AS deps +RUN npm config set registry https://package-mirror.liara.ir/repository/npm/ # Install OpenSSL for Prisma RUN apk add --no-cache openssl libc6-compat WORKDIR /app @@ -12,6 +13,7 @@ RUN npm install --ignore-scripts # Stage 2: Builder FROM node:20-alpine AS builder +RUN npm config set registry https://package-mirror.liara.ir/repository/npm/ # Install OpenSSL for Prisma RUN apk add --no-cache openssl libc6-compat WORKDIR /app @@ -49,6 +51,7 @@ RUN npm run build # Stage 3: Runner FROM node:20-alpine AS runner +RUN npm config set registry https://package-mirror.liara.ir/repository/npm/ WORKDIR /app ENV NODE_ENV=production diff --git a/public/logo svg.svg b/public/logo svg.svg new file mode 100644 index 0000000..d59c87c --- /dev/null +++ b/public/logo svg.svg @@ -0,0 +1,147 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/@core/svg/Logo.tsx b/src/@core/svg/Logo.tsx index 7915a37..3644234 100644 --- a/src/@core/svg/Logo.tsx +++ b/src/@core/svg/Logo.tsx @@ -3,34 +3,9 @@ import type { SVGAttributes } from 'react' const Logo = (props: SVGAttributes) => { return ( - - - - - - + ) } diff --git a/src/components/layout/shared/Logo.tsx b/src/components/layout/shared/Logo.tsx index c27cd9a..1b04a5a 100644 --- a/src/components/layout/shared/Logo.tsx +++ b/src/components/layout/shared/Logo.tsx @@ -71,8 +71,8 @@ const Logo = ({ color }: { color?: CSSProperties['color'] }) => { return (
- - + {/* { isBreakpointReached={isBreakpointReached} > {themeConfig.templateName} - + */}
) } diff --git a/src/configs/primaryColorConfig.ts b/src/configs/primaryColorConfig.ts index e809b24..9fced7a 100644 --- a/src/configs/primaryColorConfig.ts +++ b/src/configs/primaryColorConfig.ts @@ -15,6 +15,7 @@ export type PrimaryColorConfig = { // Primary color config object const primaryColorConfig: PrimaryColorConfig[] = [ + { id: 'palette-1', paletteKey: 'purple', @@ -94,7 +95,23 @@ const primaryColorConfig: PrimaryColorConfig[] = [ light: '#7AC5F7', dark: '#1A7BC4' } - } + }, + { + id: 'palette-6', + paletteKey: 'green', + name: 'Green Palette', + main: '#97AE48', + light: { + main: '#97AE48', + light: '#C1CF8B', + dark: '#758543' + }, + dark: { + main: '#97AE48', + light: '#C1CF8B', + dark: '#758543' + } + }, ] export default primaryColorConfig