Created
May 16, 2025 14:37
Webhook script for deploy Laravel in aaPanel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo "Starting............" | |
# Navigate to the Laravel project directory | |
echo "Navigating to the Laravel project directory" | |
cd /www/wwwroot/website|| { echo "Failed to cd into project directory"; exit 1; } | |
if [ ! -d .git ]; then | |
echo "Not a git repository!" | |
exit 1 | |
fi | |
# Fetch and hard reset to match the remote main branch | |
echo "Fetching and hard resetting to match the remote main branch" | |
echo "Fetching from origin..." | |
git -c safe.directory=/www/wwwroot/website fetch origin || { echo "Git fetch failed"; exit 1; } | |
echo "Resetting to origin/main..." | |
git -c safe.directory=/www/wwwroot/website reset --hard origin/main || { echo "Git reset failed"; exit 1; } | |
# Install only production dependencies | |
echo "Installing only production dependencies" | |
composer install --no-dev --optimize-autoloader | |
# Clear and cache the Laravel configuration | |
echo "Clearing and caching the Laravel configuration" | |
php artisan config:clear | |
php artisan config:cache | |
# Create symbolic link for storage (public storage directory) | |
echo "Creating symbolic link for storage" | |
php artisan storage:link | |
# Run database migrations (forced) | |
echo "Running database migrations (forced)" | |
php artisan migrate --force | |
# Set correct file ownership for web server access | |
echo "Setting correct file ownership for web server access" | |
chown -R www:www . 2>/dev/null | |
echo "DONE............" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment