-
-
Save jobcerto/5cb05b417f9e932b9dbb8095c13c74d1 to your computer and use it in GitHub Desktop.
Git Deploy via Webhook
This file contains 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
<?php | |
/* | |
* | |
* Lista de checagem para fazer Deploy via Webhook | |
* = = = = = = = = = = = = = = = = = = = = = = = = = = = = | |
* | |
* O servidor possui acesso via SSH? | |
* | |
* O git foi iniciado na pasta raiz? (git init --bare) | |
* | |
* O repositório esta vinculado ao git? (git remote add REPOSITÓRIO) | |
* | |
* Corrigiu o caminho para o .git na variável TARGET? | |
* | |
* Corrigiu o caminho para o repositório local na variável REPO? | |
* | |
* Definiu qual será a branch utilizada na variável BRANCH? | |
* | |
* Onde criar uma chave SSH? (raíz da hospedagem ~/.ssh) | |
* | |
* Como gerar uma chave SSH? (ssh-keygen -t rsa -C "email@seudominio.com.br") | |
* | |
* Esta chave criada esta liberada no repositório do Bitbucket? | |
* | |
* Um webhook foi criado para acionar este arquivo? | |
* | |
* Alterou o token de acesso para torná-lo único? | |
* | |
* Testou este arquivo pelo navegador e funcionou? Parabéns! | |
* | |
*/ | |
define('ACCESS_TOKEN', 'fAfj597nJDFSf6aDg5g8aRNugkhgu'); | |
define('TARGET', "/caminho/pasta/raiz"); | |
define('REPO', TARGET . '/public_html'); | |
define('BRANCH', 'master'); | |
if(isset($_GET['access_token']) && $_GET['access_token'] == ACCESS_TOKEN) { | |
echo shell_exec( | |
'cd ' . TARGET | |
. ' && git fetch --all' | |
. ' && export GIT_WORK_TREE=' . REPO | |
. ' && git checkout -f origin/' . BRANCH | |
. ' 2>&1' | |
); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment