Question

I'm running MAMP locally. I have a php script that I use to build a web site, to generate static HTML files, that I then push to a web server.

This process acts a lot like Jekyll on github pages.

For now, I simply make changes to Markdown files (my content) and then hit a local url, localhost/mysite/build, to which generates the html files. Simple.

I do have git installed locally to version the PHP script itself, along with the markdown files.

Ideally I would like to create a post-commit hook that will simply "ping" that build URL to allow it do run.

A couple things. I have been trying but the post-commit doesn't run the URL. I would like to use PHP in the post-commit file, is that possible? I don't need any validation or anything yet, just simply want to call the URL to have the process run when I commit.

I have done the chmod to make sure the script is executable.

The post-commit file is named 'post-commit', no extension.

I would think I could just add one simple line, like a file_get_contents(myurl), or something close to that.

I have been googling for a few hours now and found things that are close but not exactly right. Its really very simple, just sort of a noob with git hooks.

Thanks.

Était-ce utile?

La solution

Commit hooks are shell scripts, so it is definitely possible to either run a php script (just as you would do from cmd line) or issue a request to your URL using curl: curl --request GET --url http://stackoverflow.com -v in order to fire the build. Depending on the build time you might want to run curl in the background.

First of all, try to prepare a shell script, which runs the build. Then setup the hook itself. See Simple git post-commit hook to copy committed files to a certain folder as an example hook.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top