Skip to content

Instantly share code, notes, and snippets.

@sistematico
Created May 19, 2020 10:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sistematico/103f078295fd3d063e9adb00362f4b5c to your computer and use it in GitHub Desktop.
Save sistematico/103f078295fd3d063e9adb00362f4b5c to your computer and use it in GitHub Desktop.
Github automatic clone & pull
#!/usr/bin/env bash
#
# github - Script para receber automaticamente as mudanças feitas no Github
# LEMBRE-SE DE CONFIGURAR CORRETAMENTE SEU GIT SEM SENHA!!!
#
# Desenvolvido por Lucas Saliés Brum <lucas@archlinux.com.br>
#
# Sugestão de crontab:
# * * * * * sh -c "/usr/local/bin/github.sh" > /dev/null 2>&1
#
# Criado em: 20/12/2017 19:27:31
# Última Atualização: 04/11/2018 16:17:32
# Diretório base
base="/var/www/html/projetos"
# Sua conta no github
github="git@github.com:usuario"
# ou
# github="https://github.com/usuario"
if [ $1 ]; then
repos=("$@")
else
repos=("repositorio1" "repositorio2")
fi
for r in "${repos[@]}"; do
[ ! -d $base/$r ] && git clone $github/$r $base/$r
cd $base/$r
git pull -q origin master
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment