Skip to content

Instantly share code, notes, and snippets.

@cvega93
Forked from raco/deploy_git.sh
Last active May 28, 2020 16:22
Show Gist options
  • Save cvega93/dfac192d3d9de4fccbbf23ea207a56df to your computer and use it in GitHub Desktop.
Save cvega93/dfac192d3d9de4fccbbf23ea207a56df to your computer and use it in GitHub Desktop.
Easy automatic deploy bash for dummies
#!/bin/sh
projectname=$1;
#Para usar ejecutar sh deploy_git.sh [Nombre proyecto] [Scripts a ejecutar luego de deploy]
cd /var/www;
mkdir $projectname;
cd /var;
mkdir repo;
cd repo;
mkdir $projectname;
cd $projectname;
mkdir site.git;
cd site.git;
git init --bare;
cd hooks;
sudo touch post-receive;
myip="$(dig +short myip.opendns.com @resolver1.opendns.com)";
echo "
#!/bin/sh
cd /var/www/$projectname
git --work-tree=/var/www/$projectname --git-dir=/var/repo/$projectname/site.git checkout -f
${2}
" > post-receive;
sudo chmod +x post-receive;
green=`tput setaf 1`
reset=`tput sgr0`
echo "${green}---------LISTO PERRO YA TIENES TU REPO LEVANTADO-----${reset}
git remote add testing root@${myip}:/var/repo/$projectname/site.git
";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment