260325:1324 Refactor correspondence & rfa #02
This commit is contained in:
@@ -12,18 +12,26 @@ jobs:
|
||||
# ============================================================
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 15
|
||||
steps:
|
||||
- name: 📥 Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: � Setup Node
|
||||
# ── [1] pnpm ต้องมาก่อน setup-node เสมอ ────────────────
|
||||
- name: ⚙️ Install pnpm
|
||||
uses: pnpm/action-setup@v4
|
||||
with:
|
||||
version: 9
|
||||
|
||||
- name: ⚙️ Setup Node
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
cache: "pnpm"
|
||||
# ลบ cache: "pnpm" ออก — ใช้ volume mount บน runner แทน
|
||||
|
||||
- name: � Install pnpm
|
||||
uses: pnpm/action-setup@v4
|
||||
# ── [2] ชี้ store ไปที่ volume ที่ mount ไว้ ─────────────
|
||||
- name: 🔧 Set pnpm store path
|
||||
run: pnpm config set store-dir /root/.local/share/pnpm
|
||||
|
||||
- name: 📦 Install deps
|
||||
run: pnpm install --frozen-lockfile
|
||||
@@ -44,10 +52,14 @@ jobs:
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: 🧪 Run Tests & Coverage
|
||||
run: |
|
||||
cd backend && pnpm test
|
||||
cd ../frontend && pnpm test run
|
||||
# ── [3] แยก step — เห็น failure ได้ชัดขึ้น ──────────────
|
||||
- name: 🧪 Test backend
|
||||
run: pnpm test
|
||||
working-directory: backend
|
||||
|
||||
- name: 🧪 Test frontend
|
||||
run: pnpm test run
|
||||
working-directory: frontend
|
||||
|
||||
# ============================================================
|
||||
# JOB 2 : Deploy — Trigger Blue-Green on QNAP
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
name: CI / CD Pipeline
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main, develop]
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
# ============================================================
|
||||
# JOB 1 : CI & Quality Gate
|
||||
# ============================================================
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: 📥 Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: � Setup Node
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
cache: "pnpm"
|
||||
|
||||
- name: � Install pnpm
|
||||
uses: pnpm/action-setup@v4
|
||||
|
||||
- name: 📦 Install deps
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: 🧹 Lint
|
||||
run: pnpm lint
|
||||
|
||||
- name: 🔍 Security & quality checks
|
||||
run: |
|
||||
# UUID misuse check (ADR-019)
|
||||
if grep -r --include="*.ts" --include="*.tsx" --exclude-dir={node_modules,.next,.agents,.git,scripts,test,__tests__} "parseInt(.*uuid" .; then
|
||||
echo "❌ UUID misuse detected"
|
||||
exit 1
|
||||
fi
|
||||
# console.log check (Clean Code)
|
||||
if grep -r --include="*.ts" --include="*.tsx" --exclude-dir={node_modules,.next,.agents,.git,scripts,test,__tests__} "console.log" .; then
|
||||
echo "❌ console.log detected"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: 🧪 Run Tests & Coverage
|
||||
run: |
|
||||
cd backend && pnpm test
|
||||
cd ../frontend && pnpm test run
|
||||
|
||||
# ============================================================
|
||||
# JOB 2 : Deploy — Trigger Blue-Green on QNAP
|
||||
# ============================================================
|
||||
deploy:
|
||||
needs: build
|
||||
if: github.ref == 'refs/heads/main'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: � Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: �🚀 Trigger Deployment on QNAP
|
||||
uses: appleboy/ssh-action@v1.2.0
|
||||
with:
|
||||
host: ${{ secrets.HOST }}
|
||||
username: ${{ secrets.USERNAME }}
|
||||
password: ${{ secrets.PASSWORD }}
|
||||
port: ${{ secrets.PORT }}
|
||||
timeout: 1200s
|
||||
command_timeout: 900s
|
||||
script_stop: true
|
||||
debug: true
|
||||
script: |
|
||||
set -e
|
||||
export PATH="/share/CACHEDEV1_DATA/.qpkg/container-station/bin:/opt/bin:/usr/local/bin:/usr/bin:/bin:$PATH"
|
||||
|
||||
echo "=========================================="
|
||||
echo "Starting QNAP Deployment Process"
|
||||
echo "=========================================="
|
||||
|
||||
# Verify Docker is accessible
|
||||
if ! docker version > /dev/null 2>&1; then
|
||||
echo "✗ Docker not accessible. Check Container Station."
|
||||
exit 1
|
||||
fi
|
||||
echo "✓ Docker accessible"
|
||||
|
||||
# Sync scripts first
|
||||
echo "📂 Syncing deployment scripts..."
|
||||
cd /share/np-dms/app/source/lcbp3
|
||||
|
||||
# Check if directory exists
|
||||
if [ ! -d ".git" ]; then
|
||||
echo "✗ Git repository not found at expected path"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
git fetch origin main
|
||||
git reset --hard origin/main
|
||||
echo "✓ Code synced"
|
||||
|
||||
# Ensure scripts are executable
|
||||
chmod +x scripts/deploy.sh scripts/rollback.sh 2>/dev/null || true
|
||||
|
||||
mkdir -p /share/np-dms/app/logs
|
||||
|
||||
echo "🚀 Executing deployment..."
|
||||
./scripts/deploy.sh
|
||||
|
||||
echo "✓ Deployment completed successfully"
|
||||
Reference in New Issue
Block a user