Skip to content

5.8GitHub Actions

GitHub Actions can run a workflow on a schedule. Save the ping URL as a repository secret. Then add steps that report the start, the success and the failure.

  1. In your repository, open Settings → Secrets and variables → Actions. Add a secret named OBSRVLY_PING_URL with your ping URL.
  2. Add the steps below to your scheduled workflow.
  3. In obsrvly, set the monitor's cron expression to the workflow's cron value. Leave timezone empty, because GitHub schedules use UTC.
.github/workflows/nightly-export.yml
name: Nightly export
on:
  schedule:
    - cron: "15 2 * * *"
  workflow_dispatch:

jobs:
  export:
    runs-on: ubuntu-latest
    env:
      PING_URL: ${{ secrets.OBSRVLY_PING_URL }}
    steps:
      - name: Report start
        run: curl -fsS -m 10 --retry 3 "$PING_URL/start" > /dev/null || true

      - uses: actions/checkout@v4

      - name: Run export
        run: ./scripts/export.sh

      - name: Report success
        if: success()
        run: curl -fsS -m 10 --retry 3 "$PING_URL" > /dev/null || true

      - name: Report failure
        if: failure()
        run: curl -fsS -m 10 --retry 3 "$PING_URL/fail" > /dev/null || true

Last updated