Is there any other approach for tagging git branch using pipeline without credentials in pipeline code? I was trying to tag a git branch using Gitlab CI. With the help of this answer from this community,

How to tag source code using gitlabCI

I can successfully tag a git branch from Gitlab CI pipeline. But In that method, I noticed that we need to provide the gitlab credentials in that pipeline code. I know, we can pass that as Gitlab environment variables.
But I just need to know, is there any other method to do this operation? With a Key or Token or something rather than direct username and password?
Not sure whether my question legit? I was thinking about the security side of it.
I believe that what you need is just a Personal Access Token, or if you're a maintainer, possibly a Deploy Token. It's much safer than embedding user credentials.