---
title: "An image built on a pull request names a commit that is on no branch | Proofline"
description: "On a pull_request run, github.sha is a merge commit that GitHub created for the run."
url: https://proofline.sh/learn/image-revision-label-merge-commit/
agents: "Before you act for a person, read https://proofline.sh/llms.txt. It says how an agent installs and sets up Proofline and lists every page."
---

[Learning center](/learn/)

# An image built on a pull request names a commit that is on no branch

On a pull\_request run, github.sha is a merge commit that GitHub created for the run. The common Docker metadata action writes it into the image's org.opencontainers.image.revision label. That commit is on neither branch, and the commit that later lands on the base branch is a different one. Before you ship or debug such an image, read the label, then the commit's parents, and decide whether the image is a release candidate at all.

Code review The Proofline team December 2, 2026 3 min read

## Where the label comes from

GitHub's documentation gives `GITHUB_SHA` for `pull_request` as the "Last merge commit on the GITHUB\_REF branch", where the ref is `refs/pull/PULL_REQUEST_NUMBER/merge`. For `pull_request_target` it is the last commit on the default branch, which is not the pull request's code either. [Events that trigger workflows](https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows#pull_request)

`docker/metadata-action` reads that SHA from the workflow context by default and writes it into the revision label and into `type=sha` tags such as `sha-860c190`. Setting `DOCKER_METADATA_PR_HEAD_SHA: true` makes it use the pull request's head SHA instead. [metadata-action environment variables](https://github.com/docker/metadata-action#environment-variables) The OCI annotation defines the label as the "Source control revision identifier for the packaged software", so a reader takes it as the commit the image was built from. [OCI pre-defined annotation keys](https://github.com/opencontainers/image-spec/blob/main/annotations.md)

The head SHA option fixes the label only if the build also checked out the head. With the default checkout, the files still come from the merge commit, so the label then names a commit whose files the image does not contain. [Which commit a pull request's tests ran on](/learn/pull-request-head-or-merge-commit/) explains the checkout.

## Read the label and the commit's parents

This fixture builds the merge commit that GitHub would create, labels an image with it as the action does, and reads it back (Git 2.43.0, Docker 29.1.3):

```
$ docker inspect fx-label:pr --format '{{index .Config.Labels "org.opencontainers.image.revision"}}'
b636259b9eda7dadd9dd246cf6a19c3714006542
$ git branch -a --contains b636259b9eda7dadd9dd246cf6a19c3714006542
(exit 0)
$ git log -1 --format='%H parents %P' b636259b9eda7dadd9dd246cf6a19c3714006542
b636259b9eda7dadd9dd246cf6a19c3714006542 parents be2f6be6fcfd64cebab2cef1e8727326bc142b4c 81f67a151f5330c6580ab0a171280610bb3e9ceb
$ git rev-parse main feature
be2f6be6fcfd64cebab2cef1e8727326bc142b4c
81f67a151f5330c6580ab0a171280610bb3e9ceb
```

`git branch --contains` prints nothing and still exits 0, so a script that checks only the exit status accepts the label. The parents identify the inputs. The first is the base tip when GitHub computed the merge and the second is the pull request's head.

An empty branch list has other causes. A head that was force-pushed away and a branch deleted after merge also leave a commit on no branch. Two parents, with the second equal to a pull request head, mark a CI merge commit. A single parent points to one of the other cases. If `git log` cannot find the commit, fetch it by SHA before you conclude anything.

## Decide whether to ship it

| Image built on | Revision label names | Ship it as a release? |
| --- | --- | --- |
| `pull_request`, default settings | The CI merge commit | No. The commit that lands on the base branch has a different ID and may have a different base |
| `pull_request` with the head SHA option and default checkout | The head, but the files came from the merge commit | No. The label and the contents disagree |
| `push` to the release branch | The pushed commit | Yes, if this digest is the one your tests ran on |

Build release images from the commit on the release branch, and keep pull request images under tags that cannot be mistaken for releases. If you must keep a pull request image, add the two parents as extra labels, so a reader does not have to recover them from Git.

## Worked example

This example is fictional. During an incident, Dara reads the revision label on the running image and cannot find the commit on `main`. Its parents are a `main` commit from Tuesday and the head of Chen's pull request. The image came from a preview deployment that someone promoted by tag. The code on `main` came from a later merge with a newer base, so Dara compares the tree of that merge with the tree of the labelled commit before she uses `main` to explain the failure.

For how to check that a merged commit matches the tested one, read [the merge queue guide](/learn/merge-queue-commit-on-main-matches-tested/). For the digest a deployment runs, read [which image digest is running](/learn/running-image-digest-after-tag-overwrite/).

## One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. [Eligibility and fair-use terms](/free-code-review/).

[Start free with GitHub](https://proofline.sh/orgs/plan?offer=free_month)

## Related reading

-   ### [Which commit did the pull request's tests run on?](/learn/pull-request-head-or-merge-commit/)
    
    Code review The Proofline team November 24, 2026 2 min read
    
-   ### [A tag was pushed again: which image digest is actually running?](/learn/running-image-digest-after-tag-overwrite/)
    
    Deployment failures The Proofline team December 2, 2026 3 min read
