Files
weval-consulting/api/wedroid-git-auto.php

22 lines
810 B
PHP

<?php
/**
* WEDROID Git Auto-Push v1.0
* Auto-commits + pushes to GitHub after validated changes
*/
function gitAutoPush($label = 'auto') {
$repos = [
'/opt/wevads-arsenal' => 'arsenal',
];
$results = [];
foreach ($repos as $path => $name) {
$status = shell_exec("cd $path && git status --porcelain 2>&1 | head -5");
if (empty(trim($status))) { $results[$name] = 'clean'; continue; }
$add = shell_exec("cd $path && git add -A 2>&1");
$msg = "WEDROID auto: $label " . date('Y-m-d H:i');
$commit = shell_exec("cd $path && git commit -m '$msg' 2>&1 | tail -1");
$push = shell_exec("cd $path && git push origin master 2>&1 | tail -2");
$results[$name] = ['commit'=>trim($commit), 'push'=>trim($push)];
}
return $results;
}