Thank you for the reply.
I found the issue. It was related to the git version which we were using on self-hosted runner. When I verified the CHECKOUT log, I found that because of the older version, github actions was downloading the repo using Rest API instead of cloning it.
git version 2.17.1
Deleting the contents of <YOUR REPO>
**The repository will be downloaded using the GitHub REST API**
To create a local Git repository instead, add Git 2.18 or higher to the PATH
Downloading the archive
Writing archive to disk
Extracting the archive
Therefore, my actions was not able to the run the git command. I have upgraded the version and it fixed the issue.