CronNudge

GitHub Actions

Store the ping URL as a repository secret named CRONNUDGE_URL. The workflow below reports a start, runs the task, and reports success or failure even when the task fails.

name: Nightly backup
on:
  schedule:
    - cron: "0 3 * * *"
  workflow_dispatch:
jobs:
  backup:
    runs-on: ubuntu-latest
    env:
      CRONNUDGE_URL: ${{ secrets.CRONNUDGE_URL }}
    steps:
      - name: Tell CronNudge the job started
        run: curl -fsS -m 10 --retry 3 "$CRONNUDGE_URL/start"
      - name: Do the work
        run: ./backup.sh
      - name: Tell CronNudge how it finished
        if: always()
        run: |
          if [ "${{ job.status }}" = "success" ]; then
            curl -fsS -m 10 --retry 3 "$CRONNUDGE_URL"
          else
            curl -fsS -m 10 --retry 3 "$CRONNUDGE_URL/fail"
          fi

Longer guide: Schedule not running