Ajouter un script de déploiement avec gestion des erreurs et journalisation
All checks were successful
SSH Hello / ssh-hello (push) Successful in 2s
All checks were successful
SSH Hello / ssh-hello (push) Successful in 2s
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -2,4 +2,5 @@ node_modules/
|
|||||||
info.log
|
info.log
|
||||||
storage/
|
storage/
|
||||||
uploads/
|
uploads/
|
||||||
package-lock.json
|
package-lock.json
|
||||||
|
deploy.log
|
||||||
43
deploy.sh
Executable file
43
deploy.sh
Executable file
@@ -0,0 +1,43 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Set strict error handling
|
||||||
|
set -e # Exit immediately if a command exits with a non-zero status
|
||||||
|
set -u # Treat unset variables as an error
|
||||||
|
|
||||||
|
# Script variables
|
||||||
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
|
# Function for logging
|
||||||
|
log() {
|
||||||
|
local timestamp=$(date +"%Y-%m-%d %H:%M:%S")
|
||||||
|
echo "[$timestamp] $1"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function for cleanup on exit
|
||||||
|
cleanup() {
|
||||||
|
log "Cleaning up..."
|
||||||
|
# Add cleanup tasks here
|
||||||
|
}
|
||||||
|
|
||||||
|
# Register the cleanup function to be called on exit
|
||||||
|
trap cleanup EXIT
|
||||||
|
|
||||||
|
# Main function
|
||||||
|
main() {
|
||||||
|
log "Starting deployment..."
|
||||||
|
|
||||||
|
# Git pull force
|
||||||
|
log "Pulling latest changes from the repository..."
|
||||||
|
git pull origin main --force
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
log "Failed to pull latest changes."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Your deployment commands go here
|
||||||
|
|
||||||
|
log "Deployment completed successfully."
|
||||||
|
}
|
||||||
|
|
||||||
|
# Execute main function
|
||||||
|
main "$@"
|
||||||
Reference in New Issue
Block a user