From 353bde5fed668045bd437102b100777512960f1e Mon Sep 17 00:00:00 2001 From: Leonardo Losoviz Date: Mon, 5 Jul 2021 14:27:37 +0800 Subject: [PATCH 1/4] Fail when `git push` fails --- entrypoint.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/entrypoint.php b/entrypoint.php index 35d3931..b944ae1 100755 --- a/entrypoint.php +++ b/entrypoint.php @@ -93,7 +93,10 @@ note($message); exec("git commit --message '$commitMessage'"); - exec('git push --quiet origin ' . $config->getBranch()); + $result = exec('git push --quiet origin ' . $config->getBranch()); + if ($result === false) { + die('Command failed'); + } } else { note('No files to change'); } From a2ae37eba6e9eb521260b3e8f4180ec3d47df5c4 Mon Sep 17 00:00:00 2001 From: Leonardo Losoviz Date: Mon, 5 Jul 2021 15:04:51 +0800 Subject: [PATCH 2/4] Check $exitCode --- entrypoint.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/entrypoint.php b/entrypoint.php index b944ae1..6c226dd 100755 --- a/entrypoint.php +++ b/entrypoint.php @@ -93,8 +93,8 @@ note($message); exec("git commit --message '$commitMessage'"); - $result = exec('git push --quiet origin ' . $config->getBranch()); - if ($result === false) { + exec('git push --quiet origin ' . $config->getBranch(), $outputLines, $exitCode); + if ($exitCode > 0) { die('Command failed'); } } else { From 1e542c698b41291137b72672a1072298a71a6844 Mon Sep 17 00:00:00 2001 From: Leonardo Losoviz Date: Mon, 5 Jul 2021 15:05:28 +0800 Subject: [PATCH 3/4] Show exit code in error --- entrypoint.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.php b/entrypoint.php index 6c226dd..47654d0 100755 --- a/entrypoint.php +++ b/entrypoint.php @@ -95,7 +95,7 @@ exec("git commit --message '$commitMessage'"); exec('git push --quiet origin ' . $config->getBranch(), $outputLines, $exitCode); if ($exitCode > 0) { - die('Command failed'); + die(sprintf('Command failed with exit code %s', $exitCode)); } } else { note('No files to change'); From 8795fc8f07437b1722b0ab979ac788bd3abd8220 Mon Sep 17 00:00:00 2001 From: Leonardo Losoviz Date: Mon, 5 Jul 2021 15:07:21 +0800 Subject: [PATCH 4/4] Exec exit --- entrypoint.php | 1 + 1 file changed, 1 insertion(+) diff --git a/entrypoint.php b/entrypoint.php index 47654d0..a072cb4 100755 --- a/entrypoint.php +++ b/entrypoint.php @@ -95,6 +95,7 @@ exec("git commit --message '$commitMessage'"); exec('git push --quiet origin ' . $config->getBranch(), $outputLines, $exitCode); if ($exitCode > 0) { + exec('exit ' . $exitCode); die(sprintf('Command failed with exit code %s', $exitCode)); } } else {