ivy: flow/v1
name: Tell someone when it fails
description: A nightly script whose failure is posted to a channel, so someone can step in.

on:
  schedule: { cron: "0 2 * * *" } # nightly at 02:00 in the space's time zone

steps:
  - id: nightly
    name: Run the nightly script
    code: nightly.py # a code file of this space
  - id: done
    name: Say it worked
    post:
      to: { channel: General }
      text: The nightly script ran.
  - id: tell
    name: Say it failed
    after: nightly
    when: failed
    post:
      to: { channel: General }
      text: "The nightly script failed: {{ steps.nightly.status }}. Please have a look."
