From f5d73c5c3f7c4e77b8fe88f2cff3fafedfd172f8 Mon Sep 17 00:00:00 2001 From: Kerboul Date: Thu, 24 Apr 2025 00:20:11 +0200 Subject: [PATCH] =?UTF-8?q?Ajouter=20un=20script=20de=20d=C3=A9ploiement?= =?UTF-8?q?=20avec=20gestion=20des=20erreurs=20et=20journalisation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 ++- deploy.sh | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100755 deploy.sh diff --git a/.gitignore b/.gitignore index 0e6c051..b6d7c5f 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ node_modules/ info.log storage/ uploads/ -package-lock.json \ No newline at end of file +package-lock.json +deploy.log \ No newline at end of file diff --git a/deploy.sh b/deploy.sh new file mode 100755 index 0000000..ed7072a --- /dev/null +++ b/deploy.sh @@ -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 "$@" \ No newline at end of file