I am practically a novice to CI. I have a very simple block of code for CI that generates output.pdf, and at the last step I manage to keep output.pdf as an artifact:
But I actually want to push this output.pdf back to the repository easily visible once the pull request succeeds. I would deeply appreciate if somebody could direct me in the correct way, at least by telling me what the proper jargon for what I am asking so that I can search.
In the settings for your project, add a CI variable (which should be masked) called TOKEN and set it to hold a Personal Access Tokens. You can create a PAT in your personal settings (not the settings for the project!).
Then, to make the actual commit, do something like this in your .gitlab-ci.yml:
git config --global user.name "${GITLAB_USER_NAME}"
git config --global user.email "${GITLAB_USER_EMAIL}"
git add output.pdf
git commit -m "Updated output.pdf"
# You might want to pull --rebase here just in case someone else has pushed to this branch?
git push http://${GITLAB_USER_LOGIN}:${TOKEN}@gitlab.com/path/project master ${CI_COMMIT_BRANCH}
You might want to make this a bit more sophisticated. For example, to ensure that it doesn’t perform the commit/push when the pipeline is started by a tag rather than a commit, but hopefully this will give you a starting point.
You can see the list of available pre-defined variables that are available in pipelines on this page.