handles the case grep doesn't match, otherwise the script exits with 1 (error)

This commit is contained in:
Marc Stern 2024-08-02 12:11:16 +02:00
parent f5bbb0b851
commit 5de53cc728

View File

@ -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