There are situations that you need to integrate the git commit in your workflow pipeline. In my situation I needed to update the Dynamic AWX Inventory, which is based on a YAML file placed on our company git. The function is quite simple, it add new files commit them and push it to the git repo.
Make sure that the git repo is cloned to the Windows Filesystem and your PowerShell working directory is in that git folder.
You can extend this function with a initial clone and changing directory before commit. Running this function without a commit message will add a timestamp.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
function psgitcommit { param( [String[]] $message ) If(!$message){ $TimeStamp = get-date -f "ddMMyyyy_hhmm" $mes = "Auto update: $TimeStamp" } git add . git commit -a -m "$message" git push } cd "C:\Git\inventory" Psgitcommit -message "Done for today" #Or without a message, so it will add the timestamp. Psgitcommit |