From 5de53cc72897f7e7e5dead81205f0ed3c4958293 Mon Sep 17 00:00:00 2001 From: Marc Stern Date: Fri, 2 Aug 2024 12:11:16 +0200 Subject: [PATCH] handles the case grep doesn't match, otherwise the script exits with 1 (error) --- .github/workflows/ci.yml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9ec469c1..5e6e5839 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -51,13 +51,12 @@ jobs: run: sudo systemctl restart apache2.service - name: Search for errors/warnings in error log run: | - errors=$(grep -E ':(?error|warn)[]]' /var/log/apache2/error.log) - if [[ -n "${errors}" ]]; then - echo "Found errors/warnings in error.log" - echo "${errors}" - exit 1 - fi - exit 0 + # '|| :' handles the case grep doesn't match, otherwise the script exits with 1 (error) + errors=$(grep -E ':(?error|warn)[]]' /var/log/apache2/error.log) || : + if [[ -z "${errors}" ]]; then exit 0; fi + echo "Found errors/warnings in error.log" + echo "${errors}" + exit 1 - name: Show httpd error log if: always() run: sudo cat /var/log/apache2/error.log