Skip to content

Automate weekly-planning script

This installs the weekly planning report script in pergamon:

  • It's triggered every monday around 8:30 am
  • It creates anonymously a new page initialized (with the default template used for the weekly planning)
  • Then send an email to the swh-team@inria.fr mailing list

I did not made the script into a template and left the template-id and the hedgedoc instance hardcoded in the script. Shout out if you want me to do the extra templating.

Related to T3877

Test Plan

octo-diff:

$ $SWH_PUPPET_ENVIRONMENT_HOME/bin/octocatalog-diff --octocatalog-diff-args --no-truncate-details --to staging pergamon
Found host pergamon.softwareheritage.org
...
diff origin/production/pergamon.softwareheritage.org current/pergamon.softwareheritage.org
*******************************************
+ Concat_fragment[profile::cron::weekly-planning-bot] =>
   parameters =>
      "order": "10"
      "tag": "profile::cron::default"
      "target": "profile::cron::default"
      "content": >>>
# Cron snippet weekly-planning-bot
30 6 * * mon nobody chronic /usr/local/bin/weekly-planning-bot
<<<
*******************************************
...
+ File[/usr/local/bin/weekly-planning-bot] =>
   parameters =>
      "ensure": "present"
      "group": "root"
      "mode": "0755"
      "owner": "root"
      "content": >>>
#!/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 <<EOF
From: Weekly planning bot <$AUTHOR>
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
<<<
*******************************************
+ Package[httpie] =>
   parameters =>
      "ensure": "installed"
*******************************************
+ Profile::Cron::D[weekly-planning-bot] =>
   parameters =>
      "command": "chronic /usr/local/bin/weekly-planning-bot"
      "hour": 6
      "minute": 30
      "target": "default"
      "unique_tag": "weekly-planning-bot"
      "user": "nobody"
      "weekday": "mon"
*******************************************
*** End octocatalog-diff on pergamon.softwareheritage.org

Migrated from D7035 (view on Phabricator)

Merge request reports