nerdexam
Microsoft

GH-200 · Question #52

Scheduled workflows run on the:

Scheduled workflows in GitHub Actions always execute against the latest commit on the repository's default branch, not a pinned commit or a named schedule branch.

Author and Maintain Workflows

Question

Scheduled workflows run on the:

Options

  • Aspecified commit and branch from the workflow YAML file.
  • Blatest commit from the branch named schedule.
  • Clatest commit and branch on which the workflow was triggered.
  • Dlatest commit from the branch named main.
  • Elatest commit on the default or base branch.

Why each option

Scheduled workflows in GitHub Actions always execute against the latest commit on the repository's default branch, not a pinned commit or a named schedule branch.

Aspecified commit and branch from the workflow YAML file.

Workflow YAML files do not embed a specific commit SHA for schedule events; the schedule trigger resolves to the live default branch tip at runtime, not a statically referenced commit.

Blatest commit from the branch named schedule.

GitHub does not recognize or require a branch named 'schedule'; no such reserved branch name exists in the Actions scheduling mechanism.

Clatest commit and branch on which the workflow was triggered.

The concept of a 'branch on which the workflow was triggered' applies to push or pull_request events, not schedule events, because schedule is a time-based trigger with no associated branch push.

Dlatest commit from the branch named main.

While 'main' is a common default branch name, the correct behavior targets the repository's configured default branch regardless of its name, which may be master, develop, or any other value.

Elatest commit on the default or base branch.

Concept tested: GitHub Actions schedule trigger default branch behavior

Source: https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#schedule

Topics

#Scheduled workflows#Workflow triggers#Branch context#Workflow execution

Community Discussion

No community discussion yet for this question.

Full GH-200 Practice