GitLab: Make commit in (shared) CI runner and push to repository/open merge request I want to run a scheduled pipeline on the shared runners that is able to open a merge request on my repository. I want to run a script that checks if updates for my pinned packages exists and if yes it should update these and open a merge request with a new branch. I am using https://gitlab.com and not a self hosted GitLab instance.
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]@gitlab.com/&lt;username&gt;/example.git/': The requested URL returned error: 403

or
remote: HTTP Basic: Access denied
fatal: Authentication failed for 'https://&lt;username&gt;:@gitlab.com/&lt;username&gt;/example.git/'

My gitlab-ci.yml looks something like this
doSth:
      image: image

      script:
        - chmod 700 doSth.sh
        - chmod 700 autoUpgrade.sh
        - ./doSth.sh
        - ./autoUpgrade.sh

My autoUpgrade.sh looks something like this.
#!/bin/bash

if [[ `git status --porcelain` ]]; then
    git config --global user.email &quot;email@example.com&quot;
    git config --global user.name &quot;example&quot;
    export BRANCH_NAME=change-sth-`date +&quot;%s&quot;`
    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=&quot;ssh -i ${CI_USER_TOKEN}&quot; git push --set-upstream origin ${BRANCH_NAME}
    git push https://${CI_USER}:${CI_USER_TOKEN}@gitlab.com/${CI_PROJECT_PATH}.git ${BRANCH_NAME}
else

Is it possible to push to a new branch in my repository using the shared runners? And if yes do you know what I am doing wrong?
echo &quot;Nothing changed&quot;
fi
CI token used for code checkout is not allowed to do writes to the git repository (unlike GitHub Actions). You need to generate a new personal token and add it to secrets.
See our integration project here as a sample: https://gitlab.com/taleodor/sample-helm-cd
Note, if you search through StackOverflow, you may find several other ways to achieve this but in any case you need to explicitly pass valid credentials that are able to write to the repo.