I'm quite new with git hooks, so sorry if my question sounds dumb.
I've got a bare repo on my server, and I've set up a post-receive hook to automatically checkout the bare repo to my production directory. Then, in ST, I've set up a remote that writes to the bare repo.
This is the hook:
while read oldrev newrev ref
if [[ $ref =~ .*/master$ ]];
echo "Master ref received. Deploying master branch to production..."
git --work-tree=[prod_dir] --git-dir=[repo_dir] checkout -f
echo "Ref $ref successfully received. Doing nothing: only the master branch may be deployed on this server."
[prod_dir] and [repo_dir] are correctly set to the directories for the production and the bare repo.
Everything was working good, until I started to change the hook, specifically I added the command for composer to update just under the git command. I performed a push, and the checkout didn't work out (my production directory was not updated).
I then read online that I should place any other command right under the `done`.
Now, I've got a two questions:
1) Is there a way to get the echos from the hook directly in output of ST?
2) Is the post-receive hook triggered if the bare repo is already updated? Because after my first push (that failed) I started to edit the hook in order to test if something was wrong in there, and I kept pushing (ofcourse nothing changed in the files so the status was [up to date]). I tried to do some random stuff, such as echoing "hello" into a file, but nothing happened. I suspect that when everything is up to date, the hook is not triggered.
Supported Platforms macOS Windows We recently introduced support for additional hosting services such as GitHub Enterprise, GitLab (Cloud, Community Edition, Enterprise Edition), and...
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event
You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events