DEV Community

Stormedo
Stormedo

Posted on Originally published at stormedo.com AI-assisted

GitHub Actions schedule not running? Trigger the workflow from outside GitHub

If a workflow with on: schedule runs late or not at all while manual runs still work, you can stop depending on GitHub's scheduler. Add a workflow_dispatch trigger, then call GitHub's workflow dispatch API on a cron from outside GitHub. A dispatched run starts when the API call arrives, not when GitHub's scheduler gets to it.

This post covers the GitHub side step by step, then three ways to send the call on a timer: cron-job.org, a Cloudflare Worker, and Stormedo. Disclosure: we build Stormedo. The other two options are free, and every step before that works the same whichever one you pick.

Why scheduled workflows run late or not at all

GitHub documents these limits on the schedule event:

  • Runs can be delayed or dropped. "The schedule event can be delayed during periods of high loads of GitHub Actions workflow runs. High load times include the start of every hour. If the load is sufficiently high enough, some queued jobs may be dropped." (GitHub docs)
  • Only the default branch runs. A schedule on any other branch does nothing.
  • Five minutes is the shortest interval. (GitHub docs)
  • Public repositories stop after 60 days without activity. "In a public repository, scheduled workflows are automatically disabled when no repository activity has occurred in 60 days." (GitHub docs)

GitHub's documentation does not describe a retry or a catch-up run for a scheduled run that was dropped. Users also report schedules that stop entirely while workflow_dispatch keeps working, for example #214540, #214648 and #214650.

If you stay on GitHub's scheduler, at least move the cron off minute 0. Something like 17 6 * * * avoids the start-of-hour load GitHub mentions.

Step 1: Add workflow_dispatch

Add an empty workflow_dispatch: next to the existing schedule. Keep schedule: for now so nothing stops running before the new trigger works.

# .github/workflows/report.yml
name: Nightly report

on:
  schedule:
    - cron: '0 6 * * *'
  workflow_dispatch:

jobs:
  report:
    runs-on: ubuntu-latest
    steps:
      - run: echo "Building the report"
Enter fullscreen mode Exit fullscreen mode

Commit it to the default branch. The dispatch event only works for workflow files that exist there.

Step 2: Create a token that can do one thing

Create a fine-grained personal access token with as little access as possible:

  1. In GitHub, open Settings, then Developer settings, then Personal access tokens, then Fine-grained tokens, and select Generate new token.
  2. Pick an Expiration date. A leaked token with an expiry stays useful for less time.
  3. Under Resource owner, pick the account or organization that owns the repository. If the organization requires approval, the token stays pending until an admin approves it.
  4. Under Repository access, choose Only select repositories and pick the one repository.
  5. Under Permissions, set Actions to Read and write. That is the only permission the dispatch endpoint needs.
  6. Generate it and keep it in GITHUB_DISPATCH_TOKEN.

Step 3: Test the call once by hand

Replace OWNER, REPO and report.yml with your values, and main if your default branch has another name. The path segment can be the workflow's file name.

curl --include --request POST \
  'https://api.github.com/repos/OWNER/REPO/actions/workflows/report.yml/dispatches' \
  --header "Authorization: Bearer $GITHUB_DISPATCH_TOKEN" \
  --header 'Accept: application/vnd.github+json' \
  --data '{"ref":"main"}'
Enter fullscreen mode Exit fullscreen mode

Expect 204 No Content and a new run in the repository's Actions tab. If you send X-GitHub-Api-Version: 2026-03-10, the same call returns 200 with the run ID instead. Without the header, GitHub uses 2022-11-28 and returns 204.

If it fails:

  • 404: the owner, repository or workflow file name is wrong, or the token was created for a different repository.
  • 401: the token is wrong, expired or deleted.
  • 403: the token lacks Actions: Read and write, or you are being rate limited.
  • 422: usually the workflow on the default branch has no workflow_dispatch trigger yet, or ref names a branch that does not exist.

Get this working before you schedule anything. A scheduler that retries will not fix a 4xx.

Step 4: Send the call on a timer

Anything that can send an authenticated POST on a schedule works. Three options, from least to most setup on your side:

Option A: cron-job.org (free, no code)

cron-job.org is a free, donation-funded cron service. Create a job with the dispatches URL and your schedule, then in the job's advanced settings set the method to POST, add the Authorization and Accept headers from Step 3, and set the body to {"ref":"main"}. It can run as often as every minute and notify you when a job fails. Its FAQ gives a 30-second timeout, the job history keeps the last 50 executions, and its documentation does not describe automatic retries.

Option B: a Cloudflare Worker with a cron trigger

Cron Triggers run a Worker on a cron in UTC, and the Workers Free plan allows 5 of them per account. The token lives in a Worker secret.

# wrangler.toml
name = "report-dispatch"
main = "src/index.js"
compatibility_date = "2026-11-01"

[triggers]
crons = ["0 6 * * *"]
Enter fullscreen mode Exit fullscreen mode
// src/index.js
const DISPATCH_URL =
  "https://api.github.com/repos/OWNER/REPO/actions/workflows/report.yml/dispatches";

export default {
  async scheduled(controller, env, ctx) {
    const res = await fetch(DISPATCH_URL, {
      method: "POST",
      headers: {
        Authorization: `Bearer ${env.GITHUB_DISPATCH_TOKEN}`,
        Accept: "application/vnd.github+json",
        "User-Agent": "report-dispatch",
      },
      body: JSON.stringify({ ref: "main" }),
    });
    if (!res.ok) {
      throw new Error(`GitHub returned ${res.status}: ${await res.text()}`);
    }
  },
};
Enter fullscreen mode Exit fullscreen mode
npx wrangler secret put GITHUB_DISPATCH_TOKEN
npx wrangler deploy
Enter fullscreen mode Exit fullscreen mode

GitHub rejects API requests without a User-Agent, so set one. Throwing on a non-2xx response marks the invocation as failed in the Worker's logs. Retries, if you want them, are your code's job.

Option C: Stormedo (we build it)

Stormedo sends scheduled HTTP requests for you. A schedule sends the Step 3 request at each cron slot, retries with backoff when GitHub returns 5xx or 429 or takes longer than 50 seconds, and keeps every attempt with its status code. Header values are stored but never shown back. You can set it up in the dashboard without code, or with the API:

curl --request POST 'https://api.stormedo.com/schedules' \
  --header "Authorization: Bearer $STORMEDO_TOKEN" \
  --header 'Content-Type: application/json' \
  --header 'Idempotency-Key: github-report-dispatch' \
  --data @- <<EOF
{
  "name": "GitHub nightly report",
  "timing": {"type": "cron", "expression": "0 6 * * *", "timezone": "UTC"},
  "request": {
    "url": "https://api.github.com/repos/OWNER/REPO/actions/workflows/report.yml/dispatches",
    "headers": {
      "Authorization": "Bearer $GITHUB_DISPATCH_TOKEN",
      "Accept": "application/vnd.github+json"
    },
    "body": {"ref": "main"}
  }
}
EOF
Enter fullscreen mode Exit fullscreen mode

The free plan includes 3 schedules and 30,000 requests a month, and a schedule every 5 minutes uses about 8,640. The full guide has the dashboard walkthrough with screenshots and JavaScript and Python examples.

Which one?

  • One free call a day with no retries is enough: cron-job.org.
  • You already run code on Cloudflare: a Worker keeps it in one place.
  • You want retries on GitHub errors and a per-attempt log without writing code: Stormedo.

Step 5: Remove the schedule trigger

Once the first external call has started a run, delete the schedule: block. If both triggers stay, each slot can run twice.

on:
  workflow_dispatch:
Enter fullscreen mode Exit fullscreen mode

Dispatched runs report github.event_name as workflow_dispatch, so update any step that checks for schedule.

Things to know whichever option you pick

A 204 means GitHub accepted the dispatch, not that the job passed. The external scheduler never sees the run. Keep watching failed runs in GitHub.

A retry can start a second run. If GitHub accepts a call but the response times out, a retry may dispatch the workflow again. Make the job safe to run twice, and add a concurrency group so two runs never overlap:

concurrency:
  group: nightly-report
  cancel-in-progress: false
Enter fullscreen mode Exit fullscreen mode

Rate limits can come back as 403. GitHub signals rate limits with 403 or 429. A call every 5 minutes is 12 an hour, far below the 5,000 an hour a personal access token gets, so a 403 usually means a permission problem.

Workflow inputs go in the body. If the workflow declares inputs, send them next to ref. GitHub accepts up to 25 and uses defaults for the rest:

{"ref": "main", "inputs": {"environment": "production"}}
Enter fullscreen mode Exit fullscreen mode

Match the timezone. GitHub runs schedule crons in UTC by default. Set your external scheduler to UTC too, or the job moves when you switch.

Put the token's expiry in your calendar. An expired token returns 401 on every call, and no retry fixes that. Generate the new token, update the scheduler, then delete the old one.

Missed runs are not backfilled. If a job has to catch up after a gap (reports, syncs, cleanups), run it once by hand from the Actions tab.

If your setup hits a case this does not cover, ask in the comments and we will add it.

Top comments (0)