#! /bin/sh

generate_secure_token() {
    echo head --bytes 64 /dev/urandom | sha512sum --binary | cut --fields 1 --delimiter ' '
}

dump_log () {
    if [ -s "$1" ]; then
        stop_command_token="$(generate_secure_token)"
        echo "::group::$1"
        echo "::stop-commands::$stop_command_token"
        cat "$1"
        echo "::$stop_command_token::"
        echo '::endgroup::'
        unset stop_command_token
    fi
}

dump_log config.log
find . -name 'test-suite*.log' -printf '%P\n' | while read -r ts; do
    dump_log "$ts"
done
