fix
Some checks failed
Deploy to Private Server / deploy (push) Has been cancelled

This commit is contained in:
2025-12-23 13:57:37 +07:00
parent 334a82ac52
commit 2b49d4a51e

View File

@@ -12,13 +12,51 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Install deps - name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'
- name: Install dependencies
run: npm ci run: npm ci
- name: Build - name: Build
run: npm run build run: npm run build
- name: Deploy - name: Verify build output
run: | run: |
rm -rf /var/www/app/vite-app/timelapse-calc if [ ! -d "dist" ]; then
cp -r dist/* /var/www/app/vite-app/timelapse-calc echo "Error: dist directory not found"
exit 1
fi
- name: Deploy to server
run: |
DEPLOY_PATH="/var/www/app/vite-app/timelapse-calc"
BACKUP_PATH="/var/www/app/vite-app/timelapse-calc.backup"
# Create backup if directory exists
if [ -d "$DEPLOY_PATH" ]; then
echo "Creating backup..."
rm -rf "$BACKUP_PATH"
mv "$DEPLOY_PATH" "$BACKUP_PATH"
fi
# Create deployment directory
mkdir -p "$DEPLOY_PATH"
# Copy new build
echo "Deploying new build..."
cp -r dist/* "$DEPLOY_PATH/"
# Verify deployment
if [ $? -eq 0 ]; then
echo "Deployment successful!"
rm -rf "$BACKUP_PATH"
else
echo "Deployment failed! Restoring backup..."
rm -rf "$DEPLOY_PATH"
mv "$BACKUP_PATH" "$DEPLOY_PATH"
exit 1
fi