echo "\`\`\`" > output.txt

process_output() {
    if [ $? -eq 0 ]; then
        head -n 5 output_tmp.txt >> output.txt
        echo "... [See pipeline output for full details]" >> output.txt
        tail -n 5 output_tmp.txt >> output.txt
    else
        cat output_tmp.txt >> output.txt
    fi
}

echo "-- START Port attribution watcher --" | tee -a output.txt
python3 .ci/port_attribution_watcher.py | tee output_tmp.txt

process_output

echo "-- END Port attribution watcher --" | tee -a output.txt
echo "" >> output.txt
echo "-- START Traefik label watcher --" | tee -a output.txt

python3 .ci/traefik_label_watcher.py | tee output_tmp.txt

process_output

echo "-- END Traefik label watcher --" | tee -a output.txt
echo "\`\`\`" >> output.txt # Close the code block