Skip to content

Drop ref: github.ref From the Get-Version Caller Example #2297

Closed

Description

@ptr727

Problem

The get-version-task.yml caller example in docs/reusable-workflows.md "Adopting the Pure Functions" passes with: ref: ${{ github.ref }}. With an explicit ref, the task's actions/checkout fetches that branch and checks out its tip at fetch time. With an empty ref, checkout uses github.sha (actions/checkout src/input-helper.ts: the commit is set to github.context.sha only when ref is empty).

A caller following the example therefore computes the version on whatever the branch tip is when the job runs, not on the commit that triggered the run. In a publisher, a merge landing between dispatch and the get-version job yields:

  • a version (X.Y.Z-g<newsha>, or a stable height) describing the new tip,
  • stamped into an artifact built from github.sha,
  • tagged at target_commitish: github.sha.

The tag's embedded SHA and height then describe a different commit than the one it points at. A gh run rerun also recomputes a different version from the same GITHUB_SHA.

Evidence

The task's own input comment says empty "falls back to the caller's default checkout ref", which is the safe default. ptr727/homeassistant-purpleair#372 adopted the task with no with: block for this reason, after a local review traced the race.

Suggested fix

Drop with: ref: ${{ github.ref }} from the example, or pass ref: ${{ github.sha }}. Note that a caller should pass ref only to version a different ref deliberately, such as a scheduled run versioning develop.

🤖 Generated with Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions