vicenteguerra / git-deploy Goto Github PK
View Code? Open in Web Editor NEWPhp Script for Auto-Pull in server (Using WebHook from GitLab, GitHub and Bitbucket)
Php Script for Auto-Pull in server (Using WebHook from GitLab, GitHub and Bitbucket)
When using gitlab webhooks the field "checkout_sha"
will always be present. This causes the deployer to execute this block always which can have unwanted side effects.
if (!empty($sha)) {
// write to the log
fputs($file, "*** RESET TO HASH INITIATED ***" . "\n");
exec(GIT . " reset --hard {$sha} 2>&1", $output, $exit);
Of course this makes sense since you do not want to have merge conflicts when using an auto deploy mechanism. In our case we have local sql-lite db running in the webapp that always got deleted although it was never checked in.
Is it mean personal access token
used in GitHub or Bitbucket?
scrip need enable sheel_exec?
Not really an issue, more like a tip:
I tried to use git-deploy on a host but failed because SSH was not accessible for the apache/php user, so git pull
resulted in an error: fatal: could not spawn fork
.
I managed to get it working though, switching the remote to https, and applying git config credential.helper store
. Note that this stores the credentials on disk, so make sure this applies to your use case.
in my CI env, repo are constantly pushed and that makes deploy.log file increase in hundreds MB to GB
please add an option so we can limit how much max the log file size could grow
I can't understand why it is giving me the error... I successfully pulled manually using git, but the script gives me this error everytime i run it.
Any help?
Why am I getting the this error? I've provided a personal access token, and yet i get access denied.
I think this line needs to reference the REMOTE_REPOSITORY
defined in the config (it's not referenced anywhere else in deployer.php
). Without it git pull
is executed over HTTPS giving the following error:
fatal: could not read Username for 'https://github.com': No such device or address
Line 68 in 5da1bbb
The logic would be something like:
$_SERVER["HTTP_X_HUB_SIGNATURE"]
(GitHub token)$_SERVER["HTTP_X_GITLAB_TOKEN"]
(GitLab token)$_GET["token"]
I'll submit a pull request for this some time this week.
Documentation:
Example:
Hi, i am trying to set this git-deploy with shared hosting. a2hosting.
git is enabled and exec also enabled.
it does finds the directory.
here is how i did setup my directory in config.
define("DIR", "/home/{username}/repositories/pakistanihaider.me");
"{username}" is my account username
i created the related directory as well. and i did checked it finds the directory.
But git pull command is not being executed..??
What am i doing wrong here??
Im using Bitbucket and getting this error.
Im using master branch
I try different:
refs/branches/master
master
refs/master
branches/master
branch/master
What should I do ?
Hi, if I try to use it at Bitbucket it says:
=== ERROR: Pushed branch does not match BRANCH ===
my row for BRANCH is:
define("BRANCH", "refs/head/master");
and I have in the repo "master" as Branch, do you know where the failure is??
Thanks for your help!
I'm trying to get a project set up that automatically pulls and runs npm i && gulp --dist
. To that end, it'd be great if there was an option for command(s) to run once the pull is finished. Something like define('EXECUTE', ['array', 'of', 'sequential', 'commands']);
or define('EXECUTE', 'string of commands');
.
I'll try to look in doing this myself, and submit a pull request if I'm successful.
Hi,
I am getting this error, when call "git pull" from script:
=== ERROR: Pull failed using GIT /usr/bin/git
and DIR /home/****/public_html/test.****.de/
===
Permission denied (publickey).
fatal: Could not read from remote repository.
But when I execute "git pull" via ssh console, I dont get this error and the pull will execute.
I checked the user calling the script. It's the same user I'm signed in with via ssh.
Has anyone an idea?
I have a problem, git deploy says *** AUTO PULL SUCCESFUL *** but no files have been pulled.
Hello
I try the script but its not working in log it shows it pull but when i see the files no changes have been done
I have two branches (master/dev). I have git-deploy set up to use the dev branch.
I got this to work with one branch, however the second branch is not picking up any changes.
I made a code edit to a file in the dev branch, pushed it to gitlab. I can see in the deploy.log that it tried to deploy however it says everything is up-to-date. Am I missing something?
i follow this instruction
run sudo chown -R yourusername:webserverusername custom-project-repo-dir/ to change the group of the repo.
run sudo chmod -R g+s custom-project-repo-dir/ to make the group assignment inherited for new files/dirs.
run sudo chmod -R 775 custom-project-repo-dir/ to set read & write for both owner and group.
but, still not work "/usr/bin/git: not found". i try to run which git and get "/usr/bin/git". why?
=== ERROR: Pull failed using GIT /usr/bin/git
and DIR /var/www/html/repository
===
error: cannot open .git/FETCH_HEAD: Permission denied
This error msg found when run on php php-5.4.45 or below but no error on php-5.5.38 above
PHP message: PHP Parse error: syntax error, unexpected ')', expecting :: (T_PAAMAYIM_NEKUDOTAYIM) in xxxxxxxxxxxxxx/git-deploy/deployer.php on line 47
The grammar and wording in the README is a little confusing; I'm guessing English isn't your first language, so I'll go through and correct what I can and submit a pull request.
GitHub and GitLab have both had some pretty major UI changes since the instructions in the README where set up. Screenshots need updated to match the newest UI, and instructions may need adjusted as well. Additionally, while BitBucket is listed as having instructions, no guide currently exists for this.
I'll take a look at updating these later this week.
Hey, thanks for the script. I think I've just about got it set up and am down to the last details. Upon setting up my github webhooks and testing, the debug.log file indicates that I have issues with my host key.
I'm assuming that this has to do with the SSH key that my www-root user is using to access my github repository. I have used ssh-keygen to generate rsa keys for both my www-root user as well as my normal user. For my normal user, git pull
works fine, however when the webhook hits the deploy.php script, I receive the following error.
I tried generating the rsa key for my www-root user in it's home directory at /var/www/.ssh/
and adding the public key to github, but no cigar.
*** AUTO PULL INITIATED ***
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
*** AUTO PULL COMPLETE ***
Any thoughts? I'm not sure if this is an issue with this repo, but perhaps it's an opportunity for more clarification in the readme if it is something really simple.
Github shows my webhook failing with this error:
=== ERROR: Pull failed using GIT /usr/bin/git
and DIR /home/***/public_html/
===
[no output]
It's using application/json
.
I'm able to git pull
via ssh (as the web user) without problem.
My public key was READ ONLY, so I changed it to READ+WRITE ... same error.
I had no problem getting this to work on another site on the same VPS, the only difference being that this site uses github, whereas the working one uses gitlab.
Any advice?
Constant problems with the path
=== ERROR: DIR /D:/bkp-imobtotal/importacoes/
does not exist ===
=== ERROR: Pull failed using GIT /%ProgramFiles%/Git/git-bash.exe/
and DIR /bkp-imobtotal/importacoes/
===
The filename, directory name, or volume label syntax is incorrect.
already chechek and are all valid paths...
Any hints?
I completely forgot about this; I'll take care of it later this week.
We should probably add a check for that, as it confused me for a good 15 minutes while I was trying to figure out why it wasn't working.
With gitlab the property to compare is "target_branch" instead of "ref".
return git pull status message as response message body to the git server.
right now the response message body received by gitlab/github are blank.
For people who aren't very familiar with servers, it'd be nice to have a troubleshooting guide, walking through common problems and how to resolve them. Of course, I believe this script is really only meant to be used by advanced users, so maybe this isn't strictly necessary.
Some ideas:
I am hitting a wall and suspect it is the fact that GitHub requires OAUTH accounts to authenticate using only https using personal access tokens. I tried changing the URL to the https URL structure of
https://[account]:[personalaccesstoken]@github.com/[account]/repo.git
but still receive a "fatal: could not read Username for 'https://github.com': No such device or address" error. Any chance of support for OAUTH accounts using this method?
Hi, some docker alpine version working with this script?
thanks in advance,
Hi
I am trying to use this script for private repository, but its not working, although SSH is set up properly n gitlab but if I try to test
" fatal: could not read Username for 'https://gitlab.com': No such device or address HEAD is now at df699ba Add new file"
This can be done very simply with an .htaccess file in the same directory with the following information:
<Files "deploy.log">
Order Allow,Deny
Deny from all
</Files>
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.