🎓 A1Learner
🔍
0 of 50 lessons completed

GitHub Actions: Manual and Scheduled Triggers

A workflow can also start by hand or on a clock. Manual starts suit one-off runs, and scheduled runs suit nightly checks.

A manual trigger

This trigger adds a button. Nothing runs until someone clicks it.

on:
  workflow_dispatch:

A manual trigger with an input

The input asks for a name. The run can use that name.

on:
  workflow_dispatch:
    inputs:
      who:
        description: 'Who to greet'
        default: 'Sam'

A daily schedule

This cron pattern means 7 in the morning UTC, every day.

on:
  schedule:
    - cron: '0 7 * * *'

Reading a cron pattern

The five parts are minute, hour, day, month, and weekday. A star means every value.

'0 7 * * *'

Both triggers together

One workflow can run on a clock and by hand.

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

Example

name: Manual and Scheduled
on:
  workflow_dispatch:
    inputs:
      who:
        description: 'Who to greet'
        default: 'Sam'
  schedule:
    - cron: '0 7 * * *'
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - uses: actions/setup-node@v7
        with:
          node-version: '24'
      - run: npm test
      - run: echo "Hello, ${{ inputs.who }}"

Key points

  • Use workflow_dispatch to add a Run workflow button to the Actions tab.
  • Use inputs to ask for a value when the workflow starts by hand.
  • Use schedule to run a workflow at a set time.
  • A schedule uses cron, a five-part time pattern.
  • Scheduled times use UTC, the shared world clock.

In this example, the workflow is saved as .github/workflows/manual-and-scheduled.yml. It runs every day at 7 in the morning UTC, and it also has a Run workflow button. The input who defaults to Sam. The test job fetches the code, sets up Node 24, runs the tests, and greets the named person. The output shows both tests passing and the greeting.

Note

GitHub switches off a scheduled workflow after 60 days with no repo activity.

Try it Yourself

Edit the code, then press Run.

Running is simulated · Rust Playground

Exercise

What does the cron pattern '0 7 * * *' mean?