Is it possible to commit artifacts into the git?

This is maybe a stupid question but I cannot solve this on my own…

I use the following .gitlab-ci.yml

  image: aergus/latex
    - latexmk -pdf test.tex
      - test.pdf

When I push a change in test.tex the runner runs successfully and I can download via the web interface. However, what I would like to have is the following: the runner should deploy the generated artifact into the git. So after finishing the run, the latest pdf is checked into the git. When I pull the git later, it gives me the latest pdf…

Is this possible? If yes: how?

1 Like

That’s not really how git is supposed to be used, but in a script we call from .gitlab-ci.yml on a runner with the shell executor in some projects we call git log, I don’t see why you wouldn’t be able to call other git commands, but you will have to look into what environment variables to set to make the commit look right (e.g. have the right author with the right email).

@drscheme, Did you ever get this to work?
I’m interested to do the same, and more advanced git operations from within a gitlab-ci pipeline.

I did not work on this any further but I learned a bit more about the ci/cd stuff since I asked.

Maybe it could work like this:

  • you install git in the container
  • you check out the repo in the container (as credentials a deploy key or something like that could be used?)
  • then you git add / commit the artifact pdf to the checked out repo

In a similar fashion I was able to build myself a deploy stage that sftps a website to a server built in the build stage. But I’ve got no idea if you can modify a repository within a build stage.

PS: In case you find a solution, let us know.

1 Like

@drscheme commit trigger CI, CI will create commit that trigger CI again…

It is endless loop

There’s a [skip ci] tag that can be added to a commit, to prevent the loop.