All right, I might be slightly late but I'm hyped up for my first contribution!
Since you are already pulling from your repo, this should be somewhat straightforward, since you have probably already added some ID access. In case you haven't, you can create an Access Token with write_repository rights. Add this token to your CI/CD Variables in the project's settings (let's name it GIT_PUSH_TOKEN) Also, you'll need to install Git on your Ubuntu image.
Inside your pipeline, you'll insert the usual sequence of commands to push, which can be done in an anchor - remember that first you have to configure the Git user, in this case, the GitLab runner.
In the end, you'd have a script somewhat like this:
variables:
BRANCH_NAME: "feature-gitlab-ci"
BOT_NAME: "GitLab Runner Bot"
BOT_EMAIL: "gitlab-runner-bot@example.net"
COMMIT_MESSAGE: "Commit from runner "
stages:
- push_excel_file
.push: &push |
git config --global user.name "${BOT_NAME}"
git config --global user.email "${BOT_EMAIL}"
git add EXCEL_FILE.xlsx
git commit -m "${COMMIT_MESSAGE} ${CI_RUNNER_ID}"
git push -o ci.skip "https://whatever:${GIT_PUSH_TOKEN}@${CI_REPOSITORY_URL#*@}" $BRANCH_NAME
push_excel_file:
stage: push_excel_file
image: ubuntu:rolling
before_script:
- apt-get update
- apt-get install git -y
- git fetch
- git checkout $BRANCH_NAME
script:
- *push
ATM, whatever in the url is really whatever for what really counts is the Access Token.
BTW: this answer wouldn't have been possible if not for the legend in the following link: https://parsiya.net/blog/2021-10-11-modify-gitlab-repositories-from-the-ci-pipeline/
So catch up with him if there are still doubts. Peace!