Skip to content

trigger deploy: wrong git metadata and build context from a git worktree #5103

Open

Description

@bonesasit

Version: trigger.dev CLI 4.7.7, local deploys (not GitHub Actions or the GitHub App).

config.workspaceDir comes from pkg-types findWorkspaceDir, which looks for the nearest .git/config file. A linked worktree has a .git file, not a directory, so the lookup misses it. Two things then go wrong.

1. A worktree nested inside another checkout (for example repo/.worktrees/release): workspaceDir resolves to the outer checkout.

  • createGitMeta runs git log and git status there, so the deployment records the outer checkout's commit, branch, and dirty flag. We saw a deploy built from a clean worktree at ae22adff recorded as 23422c6f, main, dirty.
  • On the native build path, createContextArchive(config.workspaceDir, …) tars the outer checkout, not the worktree being deployed.

2. A worktree outside any checkout: workspaceDir is the worktree itself, which is correct. But getOriginUrl(join(directory, ".git/config")) reads that path as a file, and in a worktree it doesn't exist. So remoteUrl is always missing. GIT_DIR and GIT_WORK_TREE don't help, because this value never goes through git.

Suggested fix: take both values from git in the project directory: git rev-parse --show-toplevel for the workspace, and git config --get remote.origin.url for the remote. That handles worktrees and respects GIT_DIR. Today we work around the first problem by exporting GIT_DIR and GIT_WORK_TREE and refusing nested-worktree deploys. The second has no workaround short of faking a .git/config.

Activity

  1. Kulraj69 commented on Nov 8, 2026

    @Kulraj69

    Independently reproduced both cases against main at 41ad1995b30573a9b55cfaab80c3293b7c35c1f8, using Node 24.18.0 and the locked pkg-types@1.1.3.

    Fixture Observed result
    Linked worktree inside the main checkout findWorkspaceDir() selected the outer checkout. Running the current createGitMeta() with that directory returned the outer commit, main, and dirty: true, instead of the clean worktree's commit and branch.
    Linked worktree outside the main checkout Workspace resolution was correct, but remoteUrl was missing because .git/config cannot be read through the worktree's .git file.

    Each fixture had its own commit and a committed package-lock.json. As controls, git rev-parse --show-toplevel and git config --get remote.origin.url, run inside each worktree, returned the expected root and origin.

    This exercises workspace resolution and the actual metadata helper locally, not a full CLI deployment or native build archive. AI assistance was used for the investigation and tests.

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