# Trigger a git commit for static site generator

**URL:** <https://www.ruby-forum.com/t/trigger-a-git-commit-for-static-site-generator/222005>\
**Category:** NGINX\
**Created:** [August 8, 2012, 11:59pm UTC](https://www.ruby-forum.com/t/trigger-a-git-commit-for-static-site-generator/222005 "2012-08-08T23:59:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [August 8, 2012, 11:59pm UTC](https://www.ruby-forum.com/t/trigger-a-git-commit-for-static-site-generator/222005/1 "2012-08-08T23:59:14Z")

</div>

I build a small static site generator: just PUT markdown from a textarea  
to a git versioned file and post-commit markdown.sh (and little bit  
templating) to html for nginx.

The only thing I miss the commit triggerd by nginx after the PUT.

I tried it with shell ect[^1](http://forum.nginx.org/read.php?2,181239) and even netcat 😉 but nothing worked  
really nice.

Is there an easy way to commit via nginx?

thx  
klml

Posted at Nginx Forum:

> **[trigger a git commit for static site generator](https://forum.nginx.org/read.php?2,229477,229477#msg-229477)**
>
> I build a small static site generator: just PUT markdown from a textarea to a git versioned file and post-commit markdown.sh (and little bit templating) to html for nginx. The only thing I miss the commit triggerd by nginx after the PUT. I tried it...

---

<div class="post-metadata">

**Author:** ![klml](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/a8b319/32.png) [@klml](https://www.ruby-forum.com/u/klml)\
**Post date:** [August 9, 2012, 12:44am UTC](https://www.ruby-forum.com/t/trigger-a-git-commit-for-static-site-generator/222005/2 "2012-08-09T00:44:48Z")

</div>

This \*might \*work (and can be dangerous IMO):

x=“`tail -f /usr/local/nginx/logs/access.log |grep PUT |sed 's/["]//g' |awk {'print $5'}`”; while x=“PUT”; do git commit -m “Hello Igor”; done

Your logs would have to be formated like this:

8.8.8.8 [foo.bar.netdna-cdn.com](http://foo.bar.netdna-cdn.com) [08/Aug/2012:22:41:23 +0000] "PUT …  
4.2.2.2 [bar.foo.netdna-cdn.com](http://bar.foo.netdna-cdn.com) [08/Aug/2012:22:41:23 +0000] "PUT …

Regards,

Justin D. [http://www.twitter.com/jdorfman](http://www.twitter.com/jdorfman)

NetDNA [http://www.netdna.com](http://www.netdna.com)  
The Science of Acceleration

---

<div class="post-metadata">

**Author:** ![klml](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/a8b319/32.png) [@klml](https://www.ruby-forum.com/u/klml)\
**Post date:** [August 10, 2012, 12:42am UTC](https://www.ruby-forum.com/t/trigger-a-git-commit-for-static-site-generator/222005/3 "2012-08-10T00:42:48Z")

</div>

Hi Justin,

thank you for this answer

> … (and can be dangerous IMO):  
> x=“`tail -f /usr/local/nginx/logs/access.log |grep PUT |sed 's/[”]//g’  
> |awk  
> …

using tail on logs for this is very freaky;) but its a thinkable  
approach.

To get only PUT requests I used an extra PUT log in the nginx config:

```
    if ($request_method = PUT) {
        access_log /var/log/nginx/accessPUT.log;
    }

```

so I dont need to grep.

Unfortunately I dont “get over” the forced tail

x=“`tail -f /var/log/nginx/accessPUT.log`”;  
c=“PUT” //to start an endless loop  
while c=“PUT”; //  
do  
echo $x;  
#~ git commit -m “Hello Igor”;  
done

gave me noting, I expected the lines from the log.

At the moment I use, not-out-of-the-box;(, inotifywait but this works 😉  
But I will think more about tail

[http://stackoverflow.com/questions/420143/making-git-auto-commit](http://stackoverflow.com/questions/420143/making-git-auto-commit)

Posted at Nginx Forum:  
[http://forum.nginx.org/read.php?2,229477,229546#msg-229546](http://forum.nginx.org/read.php?2,229477,229546#msg-229546)
