dagger / dagger

An engine to run your pipelines in containers

Home Page:https://dagger.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Git push

sagikazarmark opened this issue · comments

What are you trying to do?

First class or at least decent support for pushing to Git repositories.

Why is this important to you?

Dagger already has first-class support for pulling from Git repositories (even if private repo support isn't trivial).

It's often important to push changes back to a repository. A couple use cases in mind:

  • Regenerate SDKs from API descriptors upon change
  • Update GitOps manifests when a new version is out

Unfortunately, feeding credentials into Git (whether it's SSH or HTTPS) is not trivial.

How are you currently working around this?

There is already an existing example using go-git: https://daggerverse.dev/mod/github.com/matipan/daggerverse/image-updater@7dafaf057c4524654903414fc3a7b5e2374f5695

Ideally, there should be a generic "git push" solution: whether it's built into Dagger or available as a separate module.

In case it's useful, I recently started a new git module. It doesn't support push, but has a clean and simple foundation to add it.

https://daggerverse.dev/mod/github.com/shykes/git

@shykes Sounds good!

What do you think would be the best way to implement authentication?

GitHub supports http+token auth, but SSH is probably still the most common way to authenticate with Git. CI systems (like GHA) probably work better with API tokens.

I would start simple, and add a []SSHKey field to the Repo state, with assorted WithSSHKey and WithSSHKeys to add them. then a Push() function that makes sure to write the ssh keys to the right place in the container, and calls git push. Start with passing the argument as-is. Then, iterate from there.

Would it make sense to add WithSSHKey to the Git object instead (or as well) so they can be used to clone private repos as well?

Would it make sense to add WithSSHKey to the Git object instead (or as well) so they can be used to clone private repos as well?

Yes that makes perfect sense.