How to Schedule a Nightly Build in GitHub Actions
on.schedule runs a workflow on a cron timetable, independent of any push.
Add on.schedule with a POSIX cron expression in UTC. The workflow runs on the default branch at each matching time.
Steps
- Add
schedule:underonwith acronentry. - Write the expression in UTC (five fields: minute hour day month weekday).
- Optionally add
workflow_dispatchso you can also run it on demand.
Workflow
.github/workflows/nightly.yml
on:
schedule:
- cron: '0 3 * * *' # 03:00 UTC every day
workflow_dispatch:
jobs:
nightly:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm ci && npm run test:fullGotchas
- Scheduled runs use the default branch only and can be delayed under platform load.
- Latchkey runs scheduled jobs on cheaper managed runners and auto-retries transient failures.
Related guides
How to Manually Trigger a Workflow With Inputs in GitHub ActionsAdd a manual Run workflow button in GitHub Actions with workflow_dispatch and typed inputs, then read the val…
How to Cancel In-Progress Runs in GitHub ActionsCancel superseded GitHub Actions runs automatically with a concurrency group and cancel-in-progress, so only…