diff --git a/site-modules/profile/files/weekly_planning_bot/weekly-planning-bot b/site-modules/profile/files/weekly_planning_bot/weekly-planning-bot index 64f84fe8..80ee3e35 100644 --- a/site-modules/profile/files/weekly_planning_bot/weekly-planning-bot +++ b/site-modules/profile/files/weekly_planning_bot/weekly-planning-bot @@ -1,41 +1,43 @@ #!/usr/bin/env bash +set -e + DEST=swh-team@inria.fr AUTHOR=swh-team@inria.fr TEMPLATE_ID="6YKT5osoST-amJQ0MusH2Q" URL="https://hedgedoc.softwareheritage.org" DATE=`date +%G-W%V` # Retrieve the template's content -TEMPLATE=`http -pb "${URL}/${TEMPLATE_ID}/download"` +TEMPLATE=`curl -s "${URL}/${TEMPLATE_ID}/download"` TEMPLATE=$(echo "$TEMPLATE" | sed -e "s/\$DATE/$DATE/g") # Create a new page initialized with the template content -RESP=`http -ph POST "${URL}/new" content-type:text/markdown <<< "$TEMPLATE"` -LOCATION=`echo "$RESP" | grep "Location:" | cut -c 11-` +RESP=`curl -s -A POST -H "Content-Type: text/markdown" "${URL}/new" --data-binary "$TEMPLATE"` +LOCATION=`echo "$RESP" | awk '{print $4}'` if [ -n "$LOCATION" ] ; then /usr/lib/sendmail -t < To: $DEST Subject: [Weekly Planning] Week $DATE Beep boop, I'm a bot. Here is the pad for the next weekly planning meeting: $LOCATION Please take a few minutes to pre-fill your part. Remote attendees: https://meet.jit.si/EquivalentCoincidencesVentureOnlySwhTeam Yours faithfully, -- The Software Heritage weekly bot EOF fi diff --git a/site-modules/profile/manifests/weekly_planning_bot.pp b/site-modules/profile/manifests/weekly_planning_bot.pp index f4261ff7..265e7569 100644 --- a/site-modules/profile/manifests/weekly_planning_bot.pp +++ b/site-modules/profile/manifests/weekly_planning_bot.pp @@ -1,30 +1,30 @@ # A bot creating a thread for people to prepare their weekly planning in the centralized # weekly report hedgedoc document class profile::weekly_planning_bot { $command = '/usr/local/bin/weekly-planning-bot' $weekly_planning_user = lookup('weekly_planning_bot::user') $weekly_planning_cron = lookup('weekly_planning_bot::cron') - $package = 'httpie'; + $package = 'curl'; ensure_packages($package) file {$command: ensure => present, mode => '0755', owner => 'root', group => 'root', source => 'puppet:///modules/profile/weekly_planning_bot/weekly-planning-bot', } profile::cron::d {'weekly-planning-bot': command => "chronic ${command}", user => $weekly_planning_user, * => $weekly_planning_cron, require => [ File[$command], Package[$package] ], } }