Github backup with bash script not working

Hi, I’m trying to setup a frontend script for updating my homeassistant repository on Github.
During the last hours i tried but I did not succeed (script appear in the frontend but doesn’t work, it works only via terminal CLI).
PS: I’m using HASSIO on RPI3.

First of all I used this command using SSH terminal: git config remote.origin.url https://User:[email protected]/MyNameOnGithub/Repository.git

Here my setup:

configuration.yaml

[...]
shell_command: !include shell_commands.yaml
script: !include_dir_named scripts
[...]

shell_commands.yaml

gitupdate: '/config/gitupdate.sh'

gitupdate.sh:

#!/bin/bash

cd /config/
git config --global user.email "[email protected]"
git config --global user.name "myGithubusername"
git add .
git status
git commit -m "Auto Backup"
git push -u origin master
exit

(into the scripts directory) gitupdate.yaml:

alias: gitupdate
sequence:
  - service: shell_command.gitupdate

groups.yaml:

[...]
default_view:
  view: yes
  name: Home
  icon: mdi:home
  entities:
    - script.gitupdate
[...]

Can someone help me?
Thank you :slight_smile:

Can you try it with an absolute path to the script?

Hi @fabaff, the only problem is that I don’t know what is the absolute path of the script (because i’m using Hass.io).
Can you help me with it?

Edit: I tried editing shell_commands.yaml:

gitupdate: '/resin-data/homeassistant/gitupdate.sh'

But it didn’t work

The homeassistant container does not have git installed so you’re probably going to have to create an addon to automate your git commits.

1 Like

@Mike1 did you ever got it working?