Giter VIP home page Giter VIP logo

simple-php-git-deploy's People

Contributors

0rca avatar aronwoost avatar bblue avatar bjoerne2 avatar cheesypoof avatar jonmunson avatar markomarkovic avatar oodavid avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

simple-php-git-deploy's Issues

Permission denied (publickey).

I'm sure this is completely my fault, but I haven't had any luck resolving the issue, and didn't know where else to turn.

I've used deploy.php successfully on a public repo (it works great, thanks!), and now I'm trying to get it going on a private repo. The deploy.php chugs along fine, and then produces this error:

Permission denied (publickey).
fatal: The remote end hung up unexpectedly

I have followed the steps here ( https://help.github.com/articles/generating-ssh-keys ) successfully. (I do have a passphrase, could that be causing problems?)

Thank you so much!

Git issue

When trying to run the deploy.php script, I get this:

Checking the environment ...

Running as .

git not available. It needs to be installed on the server for this script to work.

When I type git into ssh prompt on the server, it shows the git commands, so git is installed. Any idea what might have gone wrong?

Windows support

After some hassle I finally managed to use this library on a windows server 2008 R2. I eventually gave up using rsync due to file permission issues in NTFS, and I am now using a simpler robocopy snip instead. I also changed from tar to 7z as 7z has better support in windows.

I can put my changes in a commit and make a pull request if there's any chance of it being merged.

Host key verification failed for private repository

I am getting below error when i am running /deploy.php from browser or if i push anything in repository.

$ git clone --depth=1 --branch master [email protected]:myrepository.git /tmp/spgd-8fbc87725193f8667aff13a1372edd28/
Cloning into '/tmp/spgd-8fbc87725193f8667aff13a1372edd28'...
Host key verification failed.
fatal: Could not read from remote repository.

When i run $ git clone --depth=1 --branch master [email protected]:myrepository.git /tmp/spgd-8fbc87725193f8667aff13a1372edd28/ directly in terminal its cloning repository without any error.

I have also referred #9 but didn't help.

Separate config options

To separate concerns, configuration options would be better located in a separate file. Separation would facilitate version updates because deploy.php could be updated without having to reconfigure it. It could be like:

require __DIR__ . '/config.php';

Or maybe with the option to be up one:

array_reduce(array(__DIR__, dirname(__DIR__)), function($name, $dir) {
    if ($name && is_file("$dir/$name")) require "$dir/$name";
    else return $name;
}, 'deploy-config.php') and require __DIR__ . '/config.php';

Pushing only conent of a folder rather than whole project

I want to automatically update a live site whenever I push changes to my repository and everything that should go live is inside a "dist" folder on github. Is there any way to specify only content of this folder to be pushed to live site (preferably via a setting in deploy-config.php)? I see an option for excluding files/folders in config file, but not for including.

Git not available.

Running CentOS7, simple-php-git-deploy 1.3.1

# git --version
git version 1.8.3.1

However, github webhook log shows

Checking the environment ...

Running as <b>nginx</b>.

<div class="error"><b>git</b> not available. It needs to be installed on the server for this script to work.</div>

Host issue not sure how to setup the keys

When the deploy file runs I keep getting this error and now sure what I'm missing. Any suggestions? Which ssh key do I use?

Cloning into '/tmp/spgd-cbe1b60d9cb7e29bad7bf0ccc4c51853'...
Host key verification failed.
fatal: The remote end hung up unexpectedly

Internal Server Error

When I run the script, (some of the time) it shows
" Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, [email protected] and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request."
After taking an extremely long time to load, I'm not sure if this is simple-php-git-deploy's problem but its halting all my developing. If it is, I would be grateful if you could fix it. Thanks.

EDIT: When it happens to load, it shows
" Error encountered!
Stopping the script to prevent possible data loss.
CHECK THE DATA IN YOUR TARGET DIR!"
but when I check the target dir, it is completely intact compared to the github repo.

Items not deleted

Everything works fine, just when I delete a directory or a file in the local repo and push the commit on the remote server nothing is changed, I can see from 'top' git and rsync are called and executed just like when I edit or add a file/directory

Using HTTPS rather than SSH to retrieve a private github repo

Works brilliantly and easily with HTTPS for a public repo. I can get it to work with very little effort.

However I've been trying to get it to work with SSH and Dreamhost and getting blocked at every turn. Is there any possibility of getting the script to work with HTTPS for a private repo?

Script changes file permissions

Hi,

Your script changes the permissions. E.g. when a file has a permission 644, your script makes it 600.

I use SUPHP and therefore 600 files can't be executed.

Giving PHP the Right SSH Key

Thanks for a great script. I have a great deploy workflow up and running. My only question is how do I give PHP the right SSH key? When I make the repo private the script hangs.

chdir(TMP_DIR); => so nuch directory

Warning: chdir(): No such file or directory (errno 2) in /var/www/deploy.php on line 184

I don't think you need this chdir, as all command have their path arguements.

Perform other php function before and after updating on the server repo

Hi there !
I found this script is useful for me.
Is there a way to put any php function somewhere in the deploy.php ?
I would like to perform backup previous code files into zip file before updating the working directory and it should be able to call some function after updating the files as well.
is it possible ?

Regards,

About branch

Hi Marko, thanks for your great code, it really help me : )

There is a problem when I try to deploy with Git 1.8.2, I got error message

pathspec 'develop' did not match any file(s) known to git

, and I find the document says

When creating a shallow clone with the --depth option, this is the default, unless --no-single-branch is given to fetch the histories near the tips of all branches

I'm not sure whitch is better, to use option --no-single-branch or just clone the specified branch for deployment?

Hope to help you

wake

Calling git from PHP

I've had some issues with git. I believe you could better call a PHP git library that handles all the git actions. This fixes not only the ssh key problems but gives more controll to the deployment script. There are some pretty good git php libraries available.

500 Internal Server Error

I keep getting the error 500 when the webhook is run. I've tried chmod 777 deploy.php on the remote server, but this does not seem to work. I've tried chmod 777 deploy.php while logged in as root and as the account owner user. I'm not sure what to try.

Sending secret insecure over HTTP

With no SSL encryption sending the secret is highly insecure, any sniffer on http traffic will read the sat parameter in plain text. The script should instead use, for example, the github payload hash.

Calling a custom script after deployment

I'm working on a Symfony application that needs some additional steps to be taken after pulling git changes (clear the cache, run migrations, etc).

Just wondering if there's an undocumented way to set this script up to run my custom post-deploy script, or if it's a feature that could be added.

It would basically be a config parameter that points to any executable file, and runs it after running everything else.

Could Not Read Username

Rookie mistake, I'm sure, but where should I be looking to fix this? I am working with a private GitHub repo, and have added my server's SSH key to GitHub. Any ideas?

...
fatal: could not read Username for 'https://github.com': No such device or address
...

Error encountered!
Stopping the script to prevent possible data loss.
CHECK THE DATA IN YOUR TARGET DIR!

Can't deploy branch?

I have tried to deploy my staging branch, added it to the line
define('BRANCH', 'Staging');
But no matter what I add it always clones master?

Add Composer Support

It would be nice to see composer support.

Pagoda box uses this deploy hook to install composer packages:

if [ ! -f composer.phar ]; then curl -s http://getcomposer.org/installer | php; fi; php composer.phar install

CHECK THE DATA IN YOUR TARGET DIR!

I got this error, please help!
Error encountered!
Stopping the script to prevent possible data loss.
CHECK THE DATA IN YOUR TARGET DIR!

504 Gateway Time-out

I have set timeout for set_time_limit(30); OR set_time_limit(300000);
But It always 504 Gateway Time-out.

Permission denied on private repository (SSH keys added)

I'm using a private repository. I've already added my SSH keys and am able to do run git pull/push commands on my server (Amazon Linux) as the root user but looking to integrate with Github's webhooks using this plugin.

I've confirmed that my SECRET_ACCESS_TOKEN, REMOTE_REPOSITORY, BRANCH, and TARGET_DIR variables in my deploy-config.php are correct.

Checking the environment ...

Running as apache.

/usr/bin/git: git version 2.1.0
/usr/bin/rsync: rsync  version 3.0.6  protocol version 30

Environment OK.

Deploying [email protected]:<username>/<project-name>.git branch
to        /var/www/html/<project-name>/ ...


$ git clone --depth=1 --branch <branch> [email protected]:<username>/<project-name>.git /tmp/spgd-2cf28dc8d59c3eb61947660c8a9d13c5/
Cloning into '/tmp/spgd-2cf28dc8d59c3eb61947660c8a9d13c5'...
Host key verification failed.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Error encountered!
Stopping the script to prevent possible data loss.
CHECK THE DATA IN YOUR TARGET DIR!

Again, I'm able to run all git commands as the root user without problem. I'm also able to run this similar script without issue, but noticed that yours seemed more secure and wanted to give that a try.

Any help here would be appreciated.

Files deployed that were not updated

Hi - we have this script running and it works great for both our Dev and Prod environments. A strange thing happened today - I deployed a couple of changes to our Dev and it worked fine. Then I merged those changes with our Master branch and deployed to Prod. This time it deployed the changed files, but the whole folder of one of our plugins that was not touched. Any ideas?

Update: on closer inspection it looks like folders were updated, but not files themselves. Strange.

which command do not work

I'm trying to deploy app on AWS under nginx user. Line

        $path = trim(shell_exec('which '.$command));

return empty result. After some debug I catch the problem. The PATH variable is not exported. So the line:

        $path = trim(shell_exec('export PATH=$PATH; which '.$command));

is working for. How about fix it?

SSH vs. HTTPS

Should the application type of the webhook be set to json or urlencoded? (Does it matter?)

I'm receiving the following:

Checking the environment ...

Running as {my username}.

/usr/bin/git : git version 1.7.9.5
/usr/bin/rsync : rsync version 3.0.9 protocol version 30

Environment OK.

Deploying https://github.com/{my username}/{my repo name}.git master
to /{my domain name}/ ...

$ git clone --depth=1 --branch master https://github.com/{my username}/{my repo name}.git /tmp/spgd-4bec90563b66bae9a40edcb0b612c31b/
Cloning into '/tmp/spgd-4bec90563b66bae9a40edcb0b612c31b'...
fatal: could not read Username for 'https://github.com': No such device or address

Error encountered!
Stopping the script to prevent possible data loss.
CHECK THE DATA IN YOUR TARGET DIR!

Question: what's the purpose of the clone?

Two questions, I guess:

  1. Why clone the repo before copying it over? (this probably reveals my ignorance of dealing with files)
  2. Does the clone action copy over all files, or just changed ones? (this reveals my ignorance of git...)

Updating a Repo V. Cloning a Repo...

Just wondering if you have ever considered making an option for maintaining a repo on the server ...so that the entire repo need not be cloned before the rysnc operation takes place.

In other words, instead of cloning into tmp, you update a repo inside of tmp only pulling in changes. For large repos, this could speed things up significantly. Just an idea, thoughts?

running composer as www-data

Because in most configurations www-data has no homedir, activating composer will end up in an exception called :

The HOME or COMPOSER_HOME environment variable must be set for composer to run correctly

To prevent this Error I defined antoher const in the deploy-config called COMPOSER_HOME. The folder that's set here must be accessible for the poor homeless user ;-)

Now I could use

putenv('COMPOSER_HOME=/path/to/home');

Maybe this tip will be considered in the next version

So long
Christian

Support for multiple repos

Hi, can you please add support for auto deploy multiple repo's?
For example, adding an array into the config file.
And provide a additional GET parameter for selecting the target repo like the array index (reduce traffic).

I think it's a bad practise for placing in every repo the 2 files (deploy.php and deploy-config.php)

Can't deploy if server has "exec" and/or "shell_exec" disabled.

I have a client that has a hosting server and by security we can't allow "exec" or "shell_exec" to be executed on this server. So we can't configure and use the simple-php-git-deploy. A Workaround for this issue is to get the code from bitbucket's/github's using https. I could explain better my idea but I don't have enough technical knowledge for this, but I think some good programmer could do it.

fatal: Not a git repository

This issue has been popping up randomly and I am not sure why it is happening. Script can sit and run for weeks and then suddenly dies.

$ git --git-dir="/tmp/spgd-development-49a97353830b85b9781e00f5c99a05da/.git" --work-tree="/tmp/spgd-development-49a97353830b85b9781e00f5c99a05da/" fetch origin development
fatal: Not a git repository: '/tmp/spgd-development-49a97353830b85b9781e00f5c99a05da/.git'

My current only solution is to ssh in and delete the /tmp/spgd-development-49a97353830b85b9781e00f5c99a05da/ folder

Deployment fails from private bitbucket repo, but works from public repo

Does anybody know what could cause depolyment to fail from a private bitbucket repo? If I make the repo public it works, but as soon as I change it to private it fails. I have added my server's public ssh key (no pass phrase) as deployment key to the private bitbucket repo and a manual git pull works on my server. When I execute the deploy.php from shell I see no output.

error: refs/remotes/origin/HEAD does not point to a valid object!

Hi, I'm using your script for a private github project.
My deploy server is on google cloud compute engine (cloud VM).
After some days of working it fails with this error:
error: refs/remotes/origin/HEAD does not point to a valid object!

Why?

To resolve the problem I'm currently deleting the repository on the deploy server every time this happens and I'm cloning it again from github.

Thx

Script running as another user

I have been trying to get the scriupt to work and found that it was trying to create a folder that wasnt where I intended to

Cloning into '/tmp/spgd-d9297d72e9817373d835e0eabb71b514-1364292767'...
Could not create directory '/var/www/.ssh'.
Host key verification failed.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.

I added a whoami to be echo and it is returning www-data I would like to run it by my user. IS this possible?

chgrp "/path/to/dir/." failed: Operation not permitted (1)

The operation is successful in that all of the files transfer over successfully to the proper directory, but this error is causing the rest of the app to fail with
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1039) [sender=3.0.6]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.