changing on deploy.sh and deploy.yml
Some checks failed
Deploy Canina / deploy (push) Failing after 0s
Some checks failed
Deploy Canina / deploy (push) Failing after 0s
This commit is contained in:
parent
b62f68df68
commit
d790a8b5d3
@ -10,8 +10,8 @@ jobs:
|
||||
deploy:
|
||||
runs-on: canina
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v3
|
||||
# ✅ مرحله Checkout حذف شد! در Gitea Actions نیازی به آن نیست.
|
||||
# خود Gitea کد را در /home/runner/work/canina/canina/ دانلود میکند.
|
||||
|
||||
- name: Give execute permission to script
|
||||
run: chmod +x deploy.sh
|
||||
|
||||
91
.github/workflows/ci.yml
vendored
91
.github/workflows/ci.yml
vendored
@ -1,91 +0,0 @@
|
||||
name: CI Pipeline
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main, develop ]
|
||||
pull_request:
|
||||
branches: [ main, develop ]
|
||||
|
||||
jobs:
|
||||
backend-ci:
|
||||
name: Backend Build, Lint, Typecheck & Test
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
cache: 'npm'
|
||||
cache-dependency-path: backend/package-lock.json
|
||||
|
||||
- name: Install Backend Dependencies
|
||||
run: |
|
||||
cd backend
|
||||
npm ci
|
||||
|
||||
- name: Generate Prisma Client
|
||||
run: |
|
||||
cd backend
|
||||
npx prisma generate
|
||||
|
||||
- name: Typecheck Backend
|
||||
run: |
|
||||
cd backend
|
||||
npx tsc --noEmit
|
||||
|
||||
- name: Lint Backend
|
||||
run: |
|
||||
cd backend
|
||||
npm run lint
|
||||
|
||||
- name: Run Backend Unit Tests
|
||||
run: |
|
||||
cd backend
|
||||
npm run test
|
||||
env:
|
||||
JWT_ACCESS_SECRET: "test_access_secret_32_characters_minimum_entropy"
|
||||
JWT_REFRESH_SECRET: "test_refresh_secret_32_characters_minimum_entropy"
|
||||
|
||||
- name: Build Backend
|
||||
run: |
|
||||
cd backend
|
||||
npm run build
|
||||
|
||||
frontend-admin-ci:
|
||||
name: Admin Panel Build, Lint & Typecheck
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
cache: 'npm'
|
||||
cache-dependency-path: frontend/admin-panel/package-lock.json
|
||||
|
||||
- name: Install Admin Panel Dependencies
|
||||
run: |
|
||||
cd frontend/admin-panel
|
||||
npm ci
|
||||
|
||||
- name: Typecheck Admin Panel
|
||||
run: |
|
||||
cd frontend/admin-panel
|
||||
npx tsc --noEmit
|
||||
|
||||
- name: Lint Admin Panel
|
||||
run: |
|
||||
cd frontend/admin-panel
|
||||
npm run lint
|
||||
|
||||
- name: Build Admin Panel
|
||||
run: |
|
||||
cd frontend/admin-panel
|
||||
npm run build
|
||||
49
deploy.sh
49
deploy.sh
@ -4,10 +4,10 @@ set -e
|
||||
export DOCKER_BUILDKIT=1
|
||||
export COMPOSE_DOCKER_CLI_BUILD=1
|
||||
|
||||
# Nexus npm registry - internal (always available)
|
||||
# Nexus npm registry
|
||||
NPM_REGISTRY="http://nexus:8081/repository/bitchpedar/"
|
||||
NEXUS_HOST="nexus"
|
||||
NEXUS_IP="172.18.0.11" # IP ثابت Nexus در شبکه Docker
|
||||
NEXUS_IP="172.18.0.11"
|
||||
|
||||
BRANCH="${1:-develop}"
|
||||
echo "Starting Deployment for branch: ${BRANCH}"
|
||||
@ -31,42 +31,35 @@ else
|
||||
fi
|
||||
|
||||
mkdir -p "$TARGET_DIR"
|
||||
cd "$TARGET_DIR"
|
||||
|
||||
if [ ! -d ".git" ]; then
|
||||
echo "Cloning repository..."
|
||||
git clone -b "$BRANCH" https://git.parsaaghayi.ir/parsa/canina.git .
|
||||
# ✅ حذف شد: cd "$TARGET_DIR" (ما در روت پروژه میمانیم تا فایلها را پیدا کنیم)
|
||||
|
||||
if [ ! -d "$TARGET_DIR/.git" ]; then
|
||||
echo "Cloning repository into $TARGET_DIR..."
|
||||
git clone -b "$BRANCH" https://git.parsaaghayi.ir/parsa/canina.git "$TARGET_DIR"
|
||||
else
|
||||
echo "Pulling latest changes..."
|
||||
echo "Pulling latest changes in $TARGET_DIR..."
|
||||
cd "$TARGET_DIR"
|
||||
git fetch origin "$BRANCH"
|
||||
git reset --hard "origin/$BRANCH"
|
||||
cd - # به پوشهی قبلی برمیگردیم
|
||||
fi
|
||||
|
||||
echo "Fixing .dockerignore..."
|
||||
sed -i '/node_modules/d' .dockerignore 2>/dev/null || true
|
||||
sed -i '/node_modules/d' backend/.dockerignore 2>/dev/null || true
|
||||
sed -i '/^backend$/d' .dockerignore 2>/dev/null || true
|
||||
|
||||
echo "Disabling TS checks for fast deploy..."
|
||||
sed -i 's|tsc -b \&\& vite build|vite build|g' frontend/admin-panel/package.json 2>/dev/null || true
|
||||
sed -i 's|tsc \&\& vite build|vite build|g' frontend/admin-panel/package.json 2>/dev/null || true
|
||||
|
||||
# Copy scientificTerms.ts if needed
|
||||
cp frontend/application/lib/data/scientificTerms.ts backend/prisma/scientificTerms.ts 2>/dev/null || true
|
||||
|
||||
# Prepare docker-compose.yml in TARGET_DIR
|
||||
cp "/opt/services/canina/$COMPOSE_FILE" "$TARGET_DIR/docker-compose.yml"
|
||||
# ✅ فایلهای کانفیگ را از روت پروژه به TARGET_DIR کپی میکنیم
|
||||
echo "Copying configuration files to $TARGET_DIR..."
|
||||
cp "$COMPOSE_FILE" "$TARGET_DIR/docker-compose.yml"
|
||||
sed -i 's/- REDIS_PORT: 6379/- REDIS_PORT=6379/g' "$TARGET_DIR/docker-compose.yml" 2>/dev/null || true
|
||||
|
||||
# Prepare nginx.conf for current environment
|
||||
# 🔥 اصلاح مسیر nginx: الان در روت هستیم، پس مستقیماً کپی میکنیم
|
||||
echo "Patching nginx.conf for environment..."
|
||||
cp nginx.conf nginx.conf.tmp
|
||||
sed -i "s/__BACKEND_HOST__/${BACKEND_HOST}/g" nginx.conf.tmp
|
||||
sed -i "s/__APP_HOST__/${APP_HOST}/g" nginx.conf.tmp
|
||||
sed -i "s/__ADMIN_HOST__/${ADMIN_HOST}/g" nginx.conf.tmp
|
||||
mv nginx.conf.tmp nginx.conf
|
||||
cp nginx.conf "$TARGET_DIR/nginx.conf"
|
||||
sed -i "s/__BACKEND_HOST__/${BACKEND_HOST}/g" "$TARGET_DIR/nginx.conf"
|
||||
sed -i "s/__APP_HOST__/${APP_HOST}/g" "$TARGET_DIR/nginx.conf"
|
||||
sed -i "s/__ADMIN_HOST__/${ADMIN_HOST}/g" "$TARGET_DIR/nginx.conf"
|
||||
|
||||
# 🔥 برو به TARGET_DIR تا داکر کامپوز را آنجا اجرا کنی
|
||||
cd "$TARGET_DIR"
|
||||
|
||||
# Nexus is always available - no need to check
|
||||
echo "Using Nexus npm proxy: $NPM_REGISTRY"
|
||||
NPM_REGISTRY_ARG="--build-arg NPM_REGISTRY=${NPM_REGISTRY}"
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user