deployment/mailpipe
TSC competition notification bot a1bfd25b29 Create initial commands for automations
2024-02-14 15:48:34 +01:00

57 lines
1008 B
Bash
Executable File

#!/bin/bash -e
logfile=$(mktemp)
exec &>> $logfile
exec 100> $HOME/homepage.lock
#pwd
#whoami
file=$(mktemp)
cat > $file
finish() {
code=$?
cat $logfile >> /tmp/mailpipe.log
if [ $code -gt 0 ]
then
sendmail vizesportwart@tsc-vfl.de << EOF
From: TSC Homepage Bot <tsc-homepage@server-hh>
To: Vizesportwart <vizesportwart@tsc-vfl.de>
Date: $(date)
Subject: Failed to parse ESV mail
The parsing of the competition notification failed. Please see also the logs!
The output of the script:
$(cat $logfile)
The offending mail was this one:
$(cat $file)
EOF
fi
exit $?
}
trap finish EXIT
flock 100
cd $HOME/hugo-page
git fetch
git reset --hard origin/develop
. ~/venv-homepage/bin/activate
pip install -r scripts/read-competition-notification/requirements.txt
./scripts/read-competition-notification/run.sh -o content/turniermeldung --read-mbox $file -vv
git add content/turniermeldung
git commit -m "Automatic commit to create new competition notification"
git push origin develop
rm $file