I’m trying to setup automatic pushes of my config files to Github. I have a shell script with the following:
cd /config
git add .
git commit -m "config files on `date +'%d-%m-%Y %H:%M:%S'`"
git push origin master
And an automation that calls a service to run this script every day at 2:00 am. If I manually run the script from the terminal it works as expected, but when calling the service to run it from Home Assistant it runs everything except the final line.
So it correctly adds and commits the files, but won’t actually push them if called from HA. I’ve tried different variations of the push command to see if anything worked, but with no luck.
It’s probably an authentication issue - one way is to ensure that your output (stdout & stderr) is redirected to a file for analysis.
If you are using login/password or SSH, then the authentication information may only be available in your terminal+ssh docker instance (in HAOS for instance) and not where the automation is run.
The automation might not be running with the same login as the one that you are using to do your interactive work (homeassistant user vs root/other user).
One method is to create an application token and to checkout your repository using that.
On github it should be like