admin_ruspet/.gitea/workflows/deploy-frontend.yml

107 lines
4.0 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

name: Deploy Frontend
on:
push:
branches: [main]
env:
REPO_DIR: "/workspace/ruspet_admin_frontend"
# Обновлен URL и добавлена авторизация
REPO_URL: "https://${{ github.actor }}:${{ github.token }}@git.ruspet-preforma.ru/romanskijdev/admin_ruspet.git"
BUILD_DIR: "/var/www/admin.ruspet.tw1.ru"
jobs:
build-and-deploy:
runs-on: self-hosted
timeout-minutes: 15
steps:
- name: 📋 Deployment Info
run: |
echo "════════════════════════════════════════"
echo "🚀 Starting frontend deployment"
echo "════════════════════════════════════════"
echo "Branch: ${{ github.ref }}"
echo "Commit: ${{ github.sha }}"
echo "Author: ${{ github.actor }}"
echo "Time: $(date '+%Y-%m-%d %H:%M:%S')"
echo "Runner: $(hostname)"
echo "════════════════════════════════════════"
- name: 📦 Checkout
run: |
git config --global --add safe.directory "$REPO_DIR"
if [ -d "$REPO_DIR/.git" ]; then
echo "📦 Updating existing repo..."
cd "$REPO_DIR"
# Принудительно задаем новый URL на случай, если папка уже существует со старым
git remote set-url origin "$REPO_URL"
git fetch origin
git reset --hard origin/main
else
echo "📦 Cloning repo..."
git clone "$REPO_URL" "$REPO_DIR"
fi
- name: 💾 Cache node_modules
uses: actions/cache@v3
with:
path: |
~/.npm
$REPO_DIR/node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: 📥 Install dependencies
run: |
cd "$REPO_DIR"
npm ci
- name: 🔨 Build
run: |
cd "$REPO_DIR"
npm run build
echo "✅ Build completed"
ls -la dist/
- name: 📤 Deploy to web server
run: |
echo "📤 Deploying to $BUILD_DIR..."
sudo mkdir -p "$BUILD_DIR"
sudo rm -rf "$BUILD_DIR"/*
sudo cp -r "$REPO_DIR/dist/"* "$BUILD_DIR/"
sudo chown -R www-data:www-data "$BUILD_DIR"
sudo chmod -R 755 "$BUILD_DIR"
echo "✅ Frontend deployed successfully"
- name: ✅ Verify deployment
run: |
echo "🔍 Verifying deployment..."
if [ -f "$BUILD_DIR/index.html" ]; then
echo "✅ index.html exists"
ls -lh "$BUILD_DIR/index.html"
echo "✅ Deployment verified successfully"
else
echo "❌ index.html not found"
exit 1
fi
- name: 📊 Deployment Summary
if: always()
run: |
echo "════════════════════════════════════════"
echo "📊 DEPLOYMENT SUMMARY"
echo "════════════════════════════════════════"
echo "Status: ${{ job.status }}"
echo "Branch: ${{ github.ref }}"
echo "Commit: ${{ github.sha }}"
echo "Duration: $SECONDS seconds"
echo "════════════════════════════════════════"
if [ "${{ job.status }}" == "success" ]; then
echo "✅ Frontend deployment completed!"
echo "🌐 Available at: https://panel.ruspet-preforma.ru"
else
echo "❌ Frontend deployment failed!"
fi