mirror of
https://github.com/donaldzou/WGDashboard
synced 2025-02-26 05:58:47 +00:00
Improve build script with error handling and automated commit process
This commit is contained in:
parent
6979aef88c
commit
e6454972f4
55
src/static/app/build.sh
Executable file → Normal file
55
src/static/app/build.sh
Executable file → Normal file
@ -1,27 +1,36 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
echo "Running vite build..."
|
|
||||||
if vite build; then
|
|
||||||
echo "Vite build successful."
|
|
||||||
else
|
|
||||||
echo "Vite build failed. Exiting."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
echo "Checking for changes to commit..."
|
|
||||||
if git diff-index --quiet HEAD --; then
|
|
||||||
|
|
||||||
if git commit -a; then
|
set -e # Exit script on any command failure
|
||||||
echo "Git commit successful."
|
|
||||||
else
|
# Check if Vite is installed
|
||||||
echo "Git commit failed. Exiting."
|
if ! command -v vite &>/dev/null; then
|
||||||
exit 1
|
echo "[ERROR] Vite is not installed. Please install it before running this script."
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "No changes to commit. Skipping commit."
|
|
||||||
fi
|
|
||||||
echo "Pushing changes to remote..."
|
|
||||||
if git push; then
|
|
||||||
echo "Git push successful."
|
|
||||||
else
|
|
||||||
echo "Git push failed. Exiting."
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Check if Git is installed
|
||||||
|
if ! command -v git &>/dev/null; then
|
||||||
|
echo "[ERROR] Git is not installed. Please install it before running this script."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Run Vite build
|
||||||
|
echo "Running Vite build..."
|
||||||
|
vite build
|
||||||
|
echo "[SUCCESS] Vite build completed."
|
||||||
|
|
||||||
|
# Check if there are uncommitted changes
|
||||||
|
if ! git diff --quiet || ! git diff --cached --quiet; then
|
||||||
|
echo "Changes detected. Committing..."
|
||||||
|
|
||||||
|
git add .
|
||||||
|
git commit -m "Automated build commit at $(date '+%Y-%m-%d %H:%M:%S')"
|
||||||
|
echo "[SUCCESS] Git commit successful."
|
||||||
|
else
|
||||||
|
echo "[INFO] No changes to commit. Skipping commit."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Push changes to remote repository
|
||||||
|
echo "Pushing changes..."
|
||||||
|
git push origin "$(git rev-parse --abbrev-ref HEAD)"
|
||||||
|
echo "[SUCCESS] Changes pushed successfully."
|
||||||
|
Loading…
Reference in New Issue
Block a user