Git Hook question showing incorrect result with my solution, what I did wrong?

The Nautilus application development team was working on a git repository /opt/demo.git which is cloned under /usr/src/kodekloudrepos directory present on Storage server in Stratos DC. The team want to setup a hook on this repository, please find below more details:

Merge the feature branch into the master branch`, but before pushing your changes complete below point.

Create a post-update hook in this git repository so that whenever any changes are pushed to the master branch, it creates a release tag with name release-2023-06-15, where 2023-06-15 is supposed to be the current date. For example if today is 20th June, 2023 then the release tag must be release-2023-06-20. Make sure you test the hook at least once and create a release tag for today’s release.

Finally remember to push your changes.

this is the question and

I do this

ssh natasha@ststor01

cd /usr/src/kodekloudrepos/demo

sudo vi .git/hooks/post-update

#i
#!/bin/bash

current_date=$(date +%Y-%m-%d)
tag_name=“release-$current_date”

while read oldrev newrev refname; do
if [ “$refname” = “refs/heads/master” ]; then
git tag $tag_name
git push origin $tag_name
fi
done
#:wq
sudo chmod +x .git/hooks/post-update

sudo git checkout master
sudo git merge feature-branch-name
sudo git push origin master

what I did wrong ?

Can you edit your post and put the code in a code block please? It is the </> icon on the edit bar.

Done, please check this now

Git hooks don’t get pushed to the repo so you need to add the hook there.