Using a private Git repository for development of Addons

I have written a couple of add-ons that I have been writing and copying into the addons directory and reloading then updating. The add-ons work and the process is ok but laborious as I develop and test.

I would like to use a private Git repository to provide my add-ons to HA, I’ve got a private repo set up on GitHub.

I just can’t work out how to add my GitHub repo and put my credentials into HA/supervisor.

Am I trying to do the impossible?

(Ultimately, I’d like to connect to my local Docker Registry too so I can build on a PC rather than my Pi)

David

I’d better answer my own question now I’ve worked it out:

In GitHub create a Personal Access Token that has “repo” as the scope.

Add the GitHub repo to HA Supervisor/Add-On Store using this form of URL:

https://USERNAME:[email protected]/USERNAME/REPONAME

David

4 Likes

Thanks David! That worked for me!

The only thing is though that when I try and install the addon I have created, I get an error if the package is private - I have to make the package public to allow an install.
Are you or anyone else aware how you can authenticate when downloading the created packages from the addon installer?

Thanks!
gap

Hi gap!

My repo is private and at the top level I have a repository.json file and thee folders, one for each of my three private packages. So, all of this is private to me. I can send a screenshot if that helps explain this better.

David

Unfortunately, authentication via the link no longer works. Is there another possibility?

This is what the error message looks like.

Cmd(‘git’) failed due to: exit code(128) cmdline: git clone -v --recursive --depth=1 --shallow-submodules – https://*****:*****@github.com/***/ha-addons.git /data/addons/git/*** stderr:
'Cloning into ‘/data/addons/git/***’… remote: Support for password authentication was removed on August 13, 2021. remote: Please see About remote repositories - GitHub Docs for information on currently recommended modes of authentication. fatal: Authentication failed for ‘https://github.com/***/ha-addons.git/’ ’

There’s hope! You can add repository urls with SSH in this format: ssh://[email protected]:<username or organization>/<repository>.git and the repository cloning tool will understand and try to automatically use SSH to clone. The problem is that this method lacks 2 things:

  1. The core, which is responsible for cloning the repository, has no way of using SSH as it is not installed within its container

  2. You need to give access to the core using its ssh public key, hopefully not too much access to mitigate security issues

The good news is that number 2 is easy, you just generate an SSH key pair and register the public one as a deploy key. This is excellent as you give read only permission and is on a repository by repository basis.

The bad news is that you can’t simply SSH into the home assistant with the SSH addon, generate a SSH key pair, set it as a deploy key, then register the repository normally with an SSH url. I don’t know how to access the core to give it SSH capabilites and a key, so if anyone smarter than me knows, I’ll gadly accept the help.

Just for info, this is the error after I accessed with ssh, generated a ssh key, added it as deploy key and then tried to add the repository normally (repo name is redacted):

Cmd(‘git’) failed due to: exit code(128) cmdline: git clone -v --recursive --depth=1 --shallow-submodules – ssh://*****@*****hub.com:****/**************.git /data/addons/git/7148c34f stderr: 'Cloning into ‘/data/addons/git/7148c34f’… error: cannot run ssh: No such file or directory fatal: unable to fork ’