Lab 004: Git Hook
Requirements
The Nautilus application development team was working on a git repository /opt/apps.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
featurebranch into themasterbranch`, but before pushing your changes complete below point. -
Create a
post-updatehook in this git repository so that whenever any changes are pushed to themasterbranch, it creates a release tag with namerelease-2023-06-15, where2023-06-15is supposed to be the current date. For example if today is20th June, 2023then the release tag must berelease-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.
Steps
At the jumphost terminal, SSH to the storage server. Replace the '*******' with the user's password and turn to superuser.
sshpass -p '*******' ssh -o StrictHostKeyChecking=no natasha@172.16.238.15
sudo su
cd /usr/src/kodekloudrepos/media/
git checkout master
git merge feature
touch /opt/media.git/hooks/post-update
chmod +x /opt/media.git/hooks/post-update
vi /opt/media.git/hooks/post-update
Enter the below contents inside the hooks/post-update file and save it
#!/bin/bash
cd /opt/media.git
git_tag=release-$(date "+%Y-%m-%d")
git tag $git_tag
git push
git status
git log