mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 15:28:37 +08:00
DEV: Silence successful database migration output in github actions (#24416)
The output of db:migrate for a new database is 20k+ lines. We only need the output when an error occurs.
This commit is contained in:
21
script/silence_successful_output
Executable file
21
script/silence_successful_output
Executable file
@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Run a command and write stdout/stderr to a temporary file. Print the output only if the command exits with a non-zero exit status
|
||||
|
||||
tmp=$(mktemp)
|
||||
|
||||
echo "[silence_successful_output] Running '$@' with output silenced..." >&2
|
||||
|
||||
("$@") 2>&1 &> "$tmp"
|
||||
STATUS=$?
|
||||
|
||||
if (( $STATUS )) ; then
|
||||
echo "[silence_successful_output] '$@' failed! Output:" >&2
|
||||
cat "$tmp" >&2
|
||||
else
|
||||
echo "[silence_successful_output] '$@' succeeded!"
|
||||
fi
|
||||
|
||||
rm "$tmp"
|
||||
|
||||
exit $STATUS
|
Reference in New Issue
Block a user