Make commit in (shared) CI runner and push to repository


my goal is to run a scheduled pipeline and push sth. to my repository. So, I want to run some commands or scripts that may makes some modifications in the pipeline. And then run another script to check if there were any modifications made and if so then make a commit and push this to a new branch to my repository.

However pushing to my repository failed because whether using ssh or https the authentication is denied.

remote: You are not allowed to upload code.
fatal: unable to access 'https://gitlab-ci-token:[MASKED]': The requested URL returned error: 403

or (the token is protected/not visible here)

remote: HTTP Basic: Access denied
fatal: Authentication failed for ''

I already have read some issues which similar problems. But they all have hosted a GitLab instance on there own, which I am not I am using and the shared runners.

Is it possible to push to my repository using the shared runners? And if yes do you see if I have make a mistake?

My .gitlab-ci.yml looks sth like this.

      image: image

        - chmod 700
        - chmod 700
        - ./
        - ./

My looks sth. like this.


if [[ `git status --porcelain` ]]; then
    git config --global ""
    git config --global "example"
    export BRANCH_NAME=change-sth-`date +"%s"`
    git checkout -b ${BRANCH_NAME}
    git add -u
    git commit -m 'change sth.'
    # I tried using ssh and https
    # chmod 0400 $CI_DEPLOY_KEY
    # GIT_SSH_COMMAND="ssh -i ${CI_USER_TOKEN}" git push --set-upstream origin ${BRANCH_NAME}
    git push https://${CI_USER}:${CI_USER_TOKEN}${CI_PROJECT_PATH}.git ${BRANCH_NAME}
  echo "Nothing changed"