Skip to content

Instantly share code, notes, and snippets.

@hargup
Created June 25, 2024 12:57
Show Gist options
  • Save hargup/5260ce8744d9c528f057ec12b4320379 to your computer and use it in GitHub Desktop.
Save hargup/5260ce8744d9c528f057ec12b4320379 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Configuration
SERVER_USER="devops"
SERVER_IP="servicename.felvin.com"
SERVER_PATH="/home/devops/code/servvice-name"
# Deploy
echo "Deploying to $SERVER_USER@$SERVER_IP:$SERVER_PATH"
# Push latest changes to origin
git push origin main
# Push latest changes to the server
ssh $SERVER_USER@$SERVER_IP << EOF
cd $SERVER_PATH
git pull origin main
npm install
pm2 restart service-name
EOF
echo "Deployment complete!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment