diff --git a/data/common/common.yaml b/data/common/common.yaml --- a/data/common/common.yaml +++ b/data/common/common.yaml @@ -3139,6 +3139,12 @@ hour: 0 monthday: 1 +weekly_planning_bot::user: nobody +weekly_planning_bot::cron: + minute: 30 + hour: 6 + weekday: mon + swh::postgres::service::users: - root - zack diff --git a/site-modules/profile/files/weekly_planning_bot/weekly-planning-bot b/site-modules/profile/files/weekly_planning_bot/weekly-planning-bot new file mode 100644 --- /dev/null +++ b/site-modules/profile/files/weekly_planning_bot/weekly-planning-bot @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +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=$(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-` + +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 new file mode 100644 --- /dev/null +++ b/site-modules/profile/manifests/weekly_planning_bot.pp @@ -0,0 +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'; + +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] + ], + } +} diff --git a/site-modules/role/manifests/swh_sysadmin.pp b/site-modules/role/manifests/swh_sysadmin.pp --- a/site-modules/role/manifests/swh_sysadmin.pp +++ b/site-modules/role/manifests/swh_sysadmin.pp @@ -25,6 +25,7 @@ include profile::sentry::reverse_proxy include profile::weekly_report_bot + include profile::weekly_planning_bot include profile::monthly_report_bot include profile::opnsense::monitoring