Interview Prep/GitHub Actions/Workflow Anatomy & Execution Model

Which version of the workflow file does GitHub use for a given run?

IntermediateConceptWorkflow Anatomy & Execution Model
Answer

The file at the commit SHA associated with the event (GITHUB_SHA):

  • push: the pushed commit, so a branch can modify its own workflow.
  • pull_request: the merge commit refs/pull/N/merge, so the PR's version of the workflow runs.
  • pull_request_target, workflow_run, schedule, issue_comment: the default branch (base) version.
  • workflow_dispatch: the ref you choose when dispatching.

This is why changing a schedule on a feature branch does nothing until it is merged.

All GitHub Actions questions Roadmap: GitHub Actions

More on Workflow Anatomy & Execution Model