monorepo-split-github-action icon indicating copy to clipboard operation
monorepo-split-github-action copied to clipboard

Since using PHP, a `git push` error does not produce the run to fail

Open leoloso opened this issue 4 years ago • 2 comments

I had set-up the wrong credentials in ACCESS_TOKEN. With version 1.1 when doing git push, it printed the Git error, and the process failed.

With this new version in PHP, doing exec('git push --quiet origin ' . $config->getBranch()); also produces a Git error, but it is just printed on screen; the GitHub Action does not fail, so I get the ✔️ at the end of the run.

To fix it, something like this could work:

$output = [];
$result_code = 0;
$result = $exec('git push --quiet origin ' . $config->getBranch(), $output, $result_code);
if ($result === false) {
    die('Command failed: ' . implode(PHP_EOL, $output));
}

Or return $result_code?

leoloso avatar Jul 03 '21 15:07 leoloso

Go for it!

TomasVotruba avatar Jul 03 '21 16:07 TomasVotruba

from https://www.php.net/manual/ru/function.die.php

Beware that when using PHP on the command line, die("Error") simply prints "Error" to STDOUT and terminates the program with a normal exit code of 0.

gam6itko avatar Apr 22 '23 14:04 gam6itko