Skip to content

metadata actions supports context git, but seems to assume checkout action doesn't use path input. #616

Description

@tsteven4

Description

If we use the checkout action with the path input to set a "Relative path under $GITHUB_WORKSPACE to place the repository", and subsequently use the metadata action with the context git, then the
metadata action fails with:

Error: fatal: not a git repository (or any of the parent directories): .git

Note that the build-push action supports a Path context with the context input, and has a build-contexts input to list additional build contexts.
Note that the checkout action supports side by side checkout https://github.com/actions/checkout?tab=readme-ov-file#checkout-multiple-repos-side-by-side.

It would be useful to be able to tell the metadata action where the .git directory was. It seems the metadata action assumes context "git" => GITHUB_WORKSPACE.

docker.yml

Activity

  1. janw commented on Apr 11, 2026

    @janw

    Ran into the same issue. You can work around it by setting GIT_DIR and GIT_WORK_TREE in the step's environment:

          - name: Docker meta
            id: meta
            uses: docker/metadata-action@v5
            with:
              context: git
              images: …
              tags: |
                …
            env:
              GIT_DIR: target/.git
              GIT_WORK_TREE: target

    where target is the directory of your checked out repo relative to $GITHUB_WORKSPACE

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions