Previously the default branch name was considered to be "main", which was wrong.
To fix this, dont put the ref param to query and let Github decide default branch.
To fix this problem, my solution was getting branch names from Github api and checking for matching.
If there is no match, this time check is a tree like this exists.