I would like my post-receive hook to be responsible for updating a version file in the repo itself, under certain conditions. So, suppose I have a file version.txt in my repository, I would like the post receive hook to update a version string inside version.txt.
That would mean another push to the repo. Is this possible?
Thanks!
You can have a working directory of your repo on your server. In the post-receive, git pull on the working directory, update the version.txt as needed and commit and push. This will trigger the post-receive one more time, so be careful about how you are doing your conditional update, otherwise it will go into a cycle.
#!/bin/sh
unset GIT_DIR
cd /path/to/repo.wd
git pull
echo "new content" > version.txt
git add version.txt
git commit -m "updating version.txt"
git push origin master
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With