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

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