I work with software which uses git repository to generate (or update) some file on a disk after a successful commit. I'd like to automatically add this generated (updated) file to the git repository. It can be contained in the same or the next commit and needs to be also pushed to the remote.
I was trying to use git hooks: * pre-commit can't be used because before committing the file which I want to add is not updated * pre-push: updated file can be added and committed to the git, but I'm unable to have it pushed automatically (only first of the two commits is pushed). I'm using a script like:
pre-push: 'cp../updatedfile . ; git add updatedfile; git commit - m "msg"'
The ideal solution would be to use something which is triggered after the successfull push of the first commit and then create a second commit (containing updated file) and push them. Do you know how to resolve it?
The ideal solution would be to use something which is triggered after the successful push
That is a server-side hook, which is not what you want, since the server would not have access to the generated updated side to add and push again.
It then depends on where you push.
On GitHub or GitLab, you would have the notion of webhook (GitLab webhook here) (also in BitBucket Cloud)
The advantage is that you setup a listener for a push event: if that listener is on the client side, where those generated (updated) files are, said listener can, on a push, trigger a second commit/push (if any local updates are detected).