test deploy
This commit is contained in:
@@ -5,52 +5,41 @@ on:
|
|||||||
branches: [ "main" ]
|
branches: [ "main" ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
deploy:
|
vite-build:
|
||||||
runs-on: homesrv
|
runs-on: node-20
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- uses: actions/checkout@v4
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
- name: Build Vite app
|
||||||
- name: Install dependencies
|
working-directory: ./src
|
||||||
run: npm ci
|
|
||||||
|
|
||||||
- name: Build
|
|
||||||
run: npm run build
|
|
||||||
|
|
||||||
- name: Verify build output
|
|
||||||
run: |
|
run: |
|
||||||
if [ ! -d "dist" ]; then
|
npm ci
|
||||||
echo "Error: dist directory not found"
|
npm run build
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Deploy to server
|
- name: Upload Vite artifacts
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: vite-dist
|
||||||
|
path: dist
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: vite-build
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Download Vite artifacts
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: vite-dist
|
||||||
|
path: dist
|
||||||
|
|
||||||
|
- name: Deploy to Private Server
|
||||||
run: |
|
run: |
|
||||||
DEPLOY_PATH="/var/www/app/vite-app/timelapse-calc"
|
rm -rf /deploy/vite-app/timelapse-calc
|
||||||
BACKUP_PATH="/var/www/app/vite-app/timelapse-calc.backup"
|
cp -r dist/* /deploy/vite-app/timelapse-calc/
|
||||||
|
rm -rf dist
|
||||||
|
|
||||||
# Create backup if directory exists
|
echo "Deployment completed successfully"
|
||||||
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