This commit is contained in:
@@ -12,13 +12,51 @@ jobs:
|
||||
- name: Checkout
|
||||
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
|
||||
|
||||
- name: Build
|
||||
run: npm run build
|
||||
|
||||
- name: Deploy
|
||||
- name: Verify build output
|
||||
run: |
|
||||
rm -rf /var/www/app/vite-app/timelapse-calc
|
||||
cp -r dist/* /var/www/app/vite-app/timelapse-calc
|
||||
if [ ! -d "dist" ]; then
|
||||
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
|
||||
Reference in New Issue
Block a user