Skip to content

docs: use pull request safe git_ref and git_commit - #726

Open
zentron wants to merge 1 commit into
mainfrom
robe/pull-request-safe-git-ref-docs
Open

zentron wants to merge 1 commit into
mainfrom
robe/pull-request-safe-git-ref-docs

Conversation

@zentron

@zentron zentron commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Background

This README renders as the Marketplace listing, so its example is what people copy into their workflows. It currently suggests:

git_ref: ${{ github.ref }}
git_commit: ${{ github.sha }}

On a pull_request event those resolve to refs/pull/<n>/merge and the merge commit GitHub creates for the pull request. That commit is reachable only from the pull ref, never from a branch or a tag, so an Octopus release pinned to it can fail to resolve at deployment time. It also disagrees with what the workflow built, because a build normally checks out the branch head.

Results

Version controlled example

git_ref: ${{ github.head_ref || github.ref }}
git_commit: ${{ github.event.pull_request.head.sha || github.sha }}

Added a short paragraph under the example explaining why the two values differ on a pull request.

Inputs table

  • git_ref now suggests ${{ github.head_ref || github.ref }} and warns against ${{ github.ref }} on its own.
  • git_commit now suggests ${{ github.event.pull_request.head.sha || github.sha }} and warns against ${{ github.sha }} on its own.

Both expressions fall back to the push values on every other event, so the example still works unchanged for push, workflow_dispatch, and schedule.

Testing

Documentation only. No change to src, dist, or action.yml, so behavior is unchanged.

The pipes in || are escaped as \|\| inside the table cells, since GitHub Flavored Markdown treats an unescaped pipe as a cell delimiter even inside a code span. The example blocks are fenced code, so they are left unescaped.

Related

🤖 Generated with Claude Code

On a pull_request event, github.ref is refs/pull/<n>/merge and
github.sha is the merge commit GitHub creates for the pull request.
That commit is not reachable from any branch or tag, so an Octopus
release pinned to it can fail to deploy later. It also disagrees with
what the workflow built, since builds normally check out the branch
head.

Update the version controlled example and the git_ref and git_commit
input descriptions to use github.head_ref and
github.event.pull_request.head.sha, both of which fall back to the push
values on every other event. This matches the advice already given for
git_resources further down the README.
@zentron
zentron requested a review from a team as a code owner September 16, 2026 01:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant