Integrations

GitHub Actions

Create a heartbeat check with the same schedule as the workflow, then add one step to the end of the job that does the work. It pings only when everything before it passed.

The secret

In the repository, open Settings → Secrets and variables → Actions and add a secret named MARSOLEN_PING_URL. Its value is the check's ping URL, which is on the check's page under Ping URL:

MARSOLEN_PING_URL
https://staging.marsolen.com/ping/YOUR-PING-UUID

The ping URL needs no other credential, so anyone who reads it can ping the check. A secret keeps it out of the workflow file and out of the logs.

The step

Paste this as the last step of the job that does the work:

last step of the job
      - name: Ping Marsolen
        if: success()
        env:
          MARSOLEN_PING_URL: ${{ secrets.MARSOLEN_PING_URL }}
        run: curl -fsS -m 10 --retry 3 -o /dev/null "$MARSOLEN_PING_URL"

So a nightly backup at 03:00 UTC becomes:

.github/workflows/backup.yml
name: Nightly backup
on:
  schedule:
    - cron: "0 3 * * *"

jobs:
  backup:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: ./scripts/backup.sh

      - name: Ping Marsolen
        if: success()
        env:
          MARSOLEN_PING_URL: ${{ secrets.MARSOLEN_PING_URL }}
        run: curl -fsS -m 10 --retry 3 -o /dev/null "$MARSOLEN_PING_URL"

The check turns green on the workflow's next passing run, and a run that fails sends nothing, so the check goes red when its ping is late.

Why it is written this way

if: success() is written out

It is also the default, and that is the reason to write it. A ping from a failed run is worse than no ping: the run is red, the dashboard is green, and you now believe a broken build is a healthy one. The edit that does it looks harmless. Somebody adds if: always() to make sure the ping runs, or if: failure() || success(), and from then on every red run reports success. Written out, the condition is a decision a reviewer sees rather than an absence nobody notices.

continue-on-error hides a failure from it

A step marked continue-on-error: true, often added to get past a flaky step, is forgiven when it fails: the job stays green and success() is still true, so the ping goes. If that step matters, give it an id and require its outcome too:

a step that is allowed to fail
      - id: upload
        continue-on-error: true
        run: ./scripts/upload.sh

      - name: Ping Marsolen
        if: success() && steps.upload.outcome == 'success'
        env:
          MARSOLEN_PING_URL: ${{ secrets.MARSOLEN_PING_URL }}
        run: curl -fsS -m 10 --retry 3 -o /dev/null "$MARSOLEN_PING_URL"

The same job, not a separate one

The step goes in the job that does the work, not in a job of its own behind needs:. A separate job pings because another job finished, on another runner, under conditions that are easy to loosen without noticing. In the same job, what pings is what ran.

The curl flags

The line is the same one every check's page gives for cron. -f fails the step on a 4xx or 5xx, so a mistyped UUID makes the step red instead of looking like a ping that landed; -sS keeps the log quiet but still prints a real error; -m 10 caps each attempt at 10 seconds; --retry 3 gets past a transient network error; and -o /dev/null drops the OK the ping answers with. The URL is passed through env: and quoted, so the secret is never pasted into the script itself.

Things GitHub's scheduler does to you

The schedule is in UTC

on: schedule always reads its cron expression in UTC. Give the check the time zone UTC too, or it expects the run hours before or after it starts.

Scheduled runs start late

GitHub queues scheduled workflows and starts them when it can, often several minutes late and later still at the top of the hour, when everybody's 0 * * * * fires at once. Give the check a grace time longer than the job plus that delay, and prefer an odd minute such as 17 3 * * * to 0 3 * * *.

Schedules can be switched off

Scheduled workflows run only from the default branch, and GitHub disables them in a public repository after 60 days without activity. Both stop the pings without a failed run anywhere, which is exactly what the check is there to notice: it goes red, and you re-enable the workflow under the Actions tab.

A workflow nobody schedules cannot be late

A workflow that only runs on workflow_dispatch, or only on a push, has no schedule to be late against. Marsolen cannot tell a run that should have happened from one nobody asked for, so it cannot help with those. Monitor the scheduled workflows.

Being told about a failure at once

With the step above, a failed run is noticed when its ping is late: after the check's grace time. To be alerted on the next sweep instead, add a second step that reports the failure itself by ending the URL with /fail. Keep the success step exactly as it is.

after the ping step
      - name: Tell Marsolen the run failed
        if: failure()
        env:
          MARSOLEN_PING_URL: ${{ secrets.MARSOLEN_PING_URL }}
        run: curl -fsS -m 10 --retry 3 -o /dev/null "$MARSOLEN_PING_URL/fail"

Other ways in

For a job on a server, see cron. On Spring Boot, the starter creates and pings the check from the @Scheduled method itself. To create checks from a script or CI, see the API.