-
Notifications
You must be signed in to change notification settings - Fork 13
Monitor Git Repositories #686
Replies: 6 comments · 10 replies
-
|
I migrated this over to the Ideas section in the GitHub Discussions so that this could be addressed. To answer your question, this would be functionally possible; however, it would be more appropriate for a major version release, if introduced. The principal issue is the potential for introducing scope creep and bloat for functionality that may be better suited to its own separate tooling. This may be a consideration for adding to the next major release of Watchtower (i.e. v2.0) if there's a demand for it. |
Beta Was this translation helpful? Give feedback.
All reactions
-
|
Wow! That was a quick response! I am still looking through the code for watchtower to familiarize myself with it and would be curious to hear your thoughts on how this would fit into watchtower? I might take a stab at implementing something like this and opening a PR if I am successful? |
Beta Was this translation helpful? Give feedback.
All reactions
-
|
The Git-based functionality would revolve around providing Watchtower an alternative method for triggering container updates by first handling monitoring via the respective repository's API or using a Git operation to obtain the latest commit hashes. Then, if an updated hash is detected, triggering a rebuild of the container image, which is then used by Watchtower to perform the remaining update process. Go-Git is what I would recommend for streamlining Git-based operations. If you are interested in trying to implement this functionality, then I would be open to reviewing a PR! |
Beta Was this translation helpful? Give feedback.
All reactions
-
|
I threw together a branch that you can check out: https://github.com/nicholas-fedor/watchtower/tree/feat/add-git-monitoring I haven't had a chance to do any integration testing on it yet. If you're keen on trying it out, then you can always build it locally and then give it a shot: |
Beta Was this translation helpful? Give feedback.
All reactions
-
|
Wow! That was quick! I haven't even begun to work on this. I will test today and update with feedback. Thank you!!! |
Beta Was this translation helpful? Give feedback.
All reactions
-
|
It looks like its working up to a point. It has an issue with getting the repository. It successfully checks and identifies when an image needs to be updated (based on git commits). The issue seems to be when it tries to pull the repository. See below: |
Beta Was this translation helpful? Give feedback.
All reactions
-
|
The issue is the image name construction during Git-based builds, where appending a Git commit tag to the full image name (including existing tag) results in multiple colons. This causes Docker to reject it as an "invalid reference format." The fix is relatively simple and involves parsing the image reference to extract the base name without the tag, then constructing the new image name correctly. This ensures the built image name is valid, such as "myservices-myblink:git-2aa20276" instead of "myservices-myblink:latest:git-2aa20276". |
Beta Was this translation helpful? Give feedback.
All reactions
-
|
I have added the fix. Let me know if that works out for you! |
Beta Was this translation helpful? Give feedback.
All reactions
-
|
Thanks for testing this out and letting me know how things are looking. The problem is that when Watchtower attempts to build a Docker image from the Git repository for the "myblink" container, it fails because Docker defaults to the "master" branch, but the repository uses "main". I added an update to append the branch name to the repository URL using Docker's standard #branch syntax (repoURL + "#" + branch). Hopefully that should resolve that particular issue. |
Beta Was this translation helpful? Give feedback.
All reactions
-
|
Getting closer!! It builds from the git repository but it fails when scanning the build output. Thank you so much for taking the time to work on this. It is greatly appreciated |
Beta Was this translation helpful? Give feedback.
All reactions
-
|
Thanks for continuing to help me test this. |
Beta Was this translation helpful? Give feedback.
All reactions
-
|
Looks like we are still hitting an auth error. Edit: it works. Check this message: #686 (reply in thread) |
Beta Was this translation helpful? Give feedback.
All reactions
-
|
Nevermind, this was user error. It turns out the github auth token requires This works wonderfully now. logs below: |
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1
-
|
I had to make some minor changes to get this to build. I added my changes on top of yours and added a PR against main as this is working for me. Thanks again! #801 |
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1
-
|
I'm working on it now. |
Beta Was this translation helpful? Give feedback.
All reactions
This discussion was converted from issue #685 on September 22, 2025 17:15.
Uh oh!
There was an error while loading. Please reload this page.
-
Is your feature request related to a problem? Please describe.
Would it be possible to monitor git repositories in addition to docker images?
For instance, if I use the following docker-compose.yaml
Would it be possible to monitor the GitHub repo for new commits and when found, update the container accordingly?
Describe the solution you'd like
When commits are made to a git repo that is used as the context for a container, update the container accordingly.
Describe alternatives you've considered
Custom scripting, WUD, DIUN. WUN and DIUN do not support this either.
Additional context
No response
Beta Was this translation helpful? Give feedback.
All reactions