Kirby Auto Git Plugin

I just released a Kirby plugin: Auto Git

kirby plugin:install pedroborges/kirby-autogit

Check out the Readme for more info.

Main features

  • Works on any Kirby structure
  • Auto-commit
  • Webhook URLs for pull and push events
  • Panel widget for pushing/pulling manually
  • Localized commit messages
  • Uses panel user as commit author
  • Triggers pull and push events

Sample git log

commit 6a90707aa1083562d0b110c0e250a9d199721cc1
Author: Pedro Borges <oi@pedroborg.es>
Date:   Fri Jul 8 10:09:16 2016 -0300

    Renamed file home/brand.jpg

commit 1e2c72746f56dc36e541746c6308067ff80738e7
Author: Pedro Borges <oi@pedroborg.es>
Date:   Fri Jul 8 10:09:20 2016 -0300

    Uploaded file home/logo.jpg

commit b45561492b2548ed815b2a9a08e722dcdddbd961
Author: Bastian Allgeier <mail@getkirby.com>
Date:   Fri Jul 8 10:07:05 2016 -0300

    Created page home
5 Likes

Just when I’m evaluating git-commit-and-push-content :slight_smile:
It will be interesting to compare the two plugins.

That’s also a great plugin. When I started working on mine a couple of months ago it didn’t have some features I needed.

Today noticed git-commit-and-push-content received some nice updates since last I checked.

Be sure to checkout the roadmap to see the features I’m currently working on.

2 Likes

Just added webhook support.

Just noticed that Github’s generated tarballs doesn’t include submodules… If you tried to install Auto Git using Kirby CLI and it didn’t contain the Git library it depends on, it’s fixed now.

I chose to use composer to manage the dependency and committed the vendor folder. Afff!

There’s a new release!

[0.4.0] - 2016-07-13

###Added:

  • Panel widget with pull/push buttons.

I’m really excited about the possibilities that this release’s enhancements brings to Auto Git. Enjoy!

If you’ve been using Auto Git, I’d love to hear your feedback :wink:

[0.5.0] - 2016-07-15

Added

  • autogit() global function.
  • Auto Git now triggers its own hooks: autogit.pull and autogit.push.
  • Enable webhooks only when a remote repository has been setup.
  • Show error on the widget when a remote repository has not been setup yet.

Changed

  • Allow Auto Git to run on older Git releases, see #1.
  • Redirect to error page when webhooks secret mismatches.
  • Show Git errors on the widget when pulling/pushing.
  • Widget title to “Sync Content”.

Fixed

  • Disable button when another action is in progress.
3 Likes

Very awesome! I am using your plugin for a project and it’s working great! :slight_smile:

1 Like

Looking forward to testing your plugin :slight_smile:

1 Like

Senor Borges, this is wonderful!

I am having a few problems setting it up on the production server though (works fine locally.)
I expect to do with user access to the repository? It’s a private github repository, but I can git via the cmd line, because the server has ssh key. The panel users don’t have their own repository access that matches their name/email, but I don’t think that should matter?

current error message when loading panel:

Panel Error:
Error without a useful message :(

It happened here:
File: /var/www/XXX/site/plugins/autogit/vendor/sebastian/git/src/Git.php
Line: 136

First of all you should connect to your server via SSH and check:

  • if ssh github.com outputs a message with your username. If it doesn’t, generate an SSH key on the server and add it to your repository as deploy key with push access.
  • if you can then push and pull inside your repository on the server.

If that works, the next issue could be that the git binary is not in the $PATH of the PHP execution environment (meaning: when PHP tries to execute git in the line from the error message, it can’t find the git binary). You should check this with your hosting provider.

No, it doesn’t. :slight_smile:

Are you sure the server has a valid SSH key? Maybe via cmd line only your user has a key. Oftentimes the webserver runs with its own user (apache normally uses the user www-data). Having apache run with “your user” actually requires some extra configurations (like setting up suEXEC) that many (less serious) shared hosting providers don’t do.

Thanks @lukasbestle and @rasteiner for your suggestions. That has definitely moved me along. I’m going to detail a few steps here for anyone future-googling:
Yes, apache was using the www-data user. You can duplicate your ‘actual’ user key for use as that user too: http://stackoverflow.com/a/7307059/2989133
I also needed to connect via the command line first to acknowledge the message and add github to known hosts:
$sudo -u www-data ssh -vT git@github.com

I checked php had access to git path by comparing $which git to output of phpinfo(). And to prove it, made a php page of <?php echo exec("git status"); which should now output a message like ‘no changes added to commit’.

Although sadly enabling Autogit plugin still errors at the same place. I might try running apache as me instead, see if hat helps.

1 Like

Please take a look at this issue on Github:

I think we are close to finding a solution for this common problem. Can anyone help us out?

My conclusion is, it is better to run apache as [the user that I use to ssh into the server] rather than www-data.
Given that it is likely that you will be using this user for the initial git init anyway, and possibly other actions, it simplifies permissions, keys, etc. And, autogit seems much happier this way!

I can test it on a shared hosting with Git 2.1.4, but not before a couple days.

I would love a version where I don’t have to have a remote repository but could simply commit to the repository within the content folder. This way I could easily just pull changes to my local repository I made with the panel without committing them on my remote via ssh before pulling. I don’t want an extra remote repository. Or do I miss something here?

That works just fine, Auto Git does not require you to set up any remotes. :slight_smile:

And how? I only get:

"Could not detect remote repository ."

After installing it as submodule and pushing it to my live system. :neutral_face:

Sorry, from your two messages I couldn’t understand exactly what you are trying to accomplish. Could you provide more info on how your setup looks like and what do you want to do?

Also, what version of Auto Git are you using?