You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.5 KiB
52 lines
1.5 KiB
#!/bin/bash |
|
|
|
#====NEED TO AUTOMATE AUTH IN ADVANCE: |
|
#(check for and create if missing on server) |
|
#mkdir -p ~/.ssh |
|
#chmod 700 ~/.ssh |
|
#touch ~/.ssh/authorized_keys |
|
#chmod 600 ~/.ssh/authorized_keys |
|
#(run these on local) |
|
#ssh-keygen -t ed25519 |
|
#ssh-copy-id rdrew@newspapers2.islandarchives.ca |
|
# -------------------------------------------------------- |
|
|
|
# --- CONFIGURATION (Edit these for new environments) --- |
|
SERVER="newspapers2.islandarchives.ca" |
|
THEME_DIR="/var/www/islandnewspapers2/web/themes/custom/olivesnews" |
|
SITE_ROOT="/var/www/islandnewspapers2/web/sites/islandnewspapers2" |
|
DRUSH_PATH="/var/www/islandnewspapers2/vendor/drush/drush/drush" |
|
# -------------------------------------------------------- |
|
|
|
# 1. Check if a commit message was provided |
|
if [ -z "$1" ]; then |
|
echo "❌ Error: Please provide a commit message." |
|
echo "Usage: ./deploy.sh 'Your message here'" |
|
exit 1 |
|
fi |
|
|
|
COMMIT_MSG="$1" |
|
|
|
echo "🚀 Starting deployment workflow..." |
|
|
|
# 2. Local Git workflow |
|
echo "📦 Committing and pushing local changes..." |
|
git add --all |
|
git commit -m "$COMMIT_MSG" |
|
git push |
|
|
|
# 3. Remote Server workflow |
|
echo "🔗 Connecting to $SERVER..." |
|
|
|
# We wrap the remote commands in a single string for SSH |
|
# The '&&' ensures that if one step fails, the script stops immediately. |
|
ssh "$SERVER" " |
|
echo '📥 Pulling code into theme folder...' && \ |
|
cd $THEME_DIR && \ |
|
git pull && \ |
|
echo '🧹 Rebuilding Drupal cache...' && \ |
|
cd $SITE_ROOT && \ |
|
$DRUSH_PATH cr |
|
" |
|
|
|
echo "✅ Done! Deployment successful."
|
|
|