Day 34: Git Hook

Hello Everyone,
i am working on day 34 of 100 days of devops. while doing task i successfully created release tag of todays date but still gives issue that - seems like ‘post-update’ hook is not working. i am attaching screenshot please check and give me any suggestion or any another solution if i wrong.

Hey @sasiram

Here’s a few things to make sure that you’re doing the right thing (just cos your request doesn’t contain a lot of detail, let’s ensure you have the following down):

  1. Make sure that your hook is setup on your bare repo (i.e. /opt/official.git or whatever the question throws at you)
  2. Here’s a snippet of the git hook that worked for me:
#My question was on /opt/media.git folder so-- /opt/media.git/hooks/post-update

#!/usr/bin/sh

# Arguments to post-update
DATE=$(date +%F)        # YYYY-MM-DD
GIT_DIR=$(pwd)

        echo "Creating tag release-$DATE"
        git --git-dir="$GIT_DIR" tag "release-$DATE" master

and rememember to make the file executable chmod +x /opt/media.git/hooks/post-update

  1. In this post , I outline what had me stuck for a few days. I was tagging the release but also forcing the tag unto subsequent commits (cos I was worried that the system would attempt to commit and get a failure). I now believe that I was marked wrong cos I did a git tag -f
  2. change dir into your working directory (in my case it was: cd /usr/src/kodekloudrepos/media
    You should be on the “feature branch”, so switch to “master”
git checkout master
git merge feature
git push

Please let me know if any of that helped.

cheers.