Skip to content

feat: build the deploy artefact without credentials, then deploy it later (deploy --build-only / --from) #5182

Backlog

Description

@Justify-social

Is your feature request related to a problem? Please describe.

We prove unmerged code in CI before it lands on the default branch. That proof should include building the exact deploy artefact for our tasks, so that a broken bundle is caught before merge. Then, once the change is on the default branch, a separate trusted job ships that same artefact.

The rule we follow is common: a job that runs unmerged code never holds a production credential. Today trigger deploy can't be split that way. In v4.9.3:

  • deploy calls authenticateForProject before anything else. That covers --dry-run too, which fails with "You must login first" if TRIGGER_ACCESS_TOKEN is absent.
  • On the local-build path, the bundle step (buildWorker) also fetches the environment's variables and the forced externals through the project client, so it needs the token as well.
  • The hidden --from-bundle <dir> flag can consume a pre-built bundle. But no public, tokenless command produces that bundle, and --from-bundle is marked internal and conflicts with the native build server.

So the choice today is to hand the token to a job running unmerged code, or to build the deploy artefact only after merge, which puts the whole bundle and image build on the release critical path.

Describe the solution you'd like to see

Split deploy into a tokenless build and a credentialed ship, for example:

# Job 1: unmerged code, no credentials. Fully offline with respect to Trigger.dev.
trigger deploy --build-only --output ./trigger-artefact   # or an image ref: --output registry/repo:tag

# Job 2: default branch only, holds TRIGGER_ACCESS_TOKEN.
trigger deploy --from ./trigger-artefact --env prod [--skip-promotion]

Properties that would make this useful:

  1. --build-only makes no API call and needs no token. Anything it would have fetched (env vars for the build, forced externals) is either not needed to bundle or is resolved in the second step.
  2. The output is content-addressed, with contentHash in build.json and, if an image is built, its digest, so the second step can prove it ships exactly what was built and tested.
  3. --from registers and pushes that artefact without re-bundling. If it builds the image, it does so deterministically from the bundle. If the first step produced an image, it pushes that image with its digest preserved.
  4. It is documented and supported, not an internal flag. --from-bundle already looks like most of the second half.

Describe alternate solutions

  • Build with the token at the PR stage, using --skip-promotion: this still places a production credential beside unmerged build scripts.
  • GitHub OIDC trusted deploys: these remove the stored token, but the job running unmerged code still obtains a deploy credential. --local-bundle and --from-bundle are also refused with OIDC.
  • Build only after merge: this is safe, but it adds several minutes to every release.
  • Use --dry-run as the proof: this needs the token too, and it doesn't produce an artefact that can be shipped later.

Additional information

Checked against trigger.dev@4.9.3 (dist/esm/commands/deploy.js: _deployCommand, handleFromBundleDeploy; dist/esm/deploy/trustedDeploy.js). I couldn't find an existing issue or discussion asking for this. Happy to test a prerelease.

Activity

  1. Justify-social commented on Dec 6, 2026

    @Justify-social
    Author

    I've implemented this on a fork branch, and I've asked for a vouch in #5010 so I can open it as a draft PR: main...Justify-social:trigger.dev:cli-deploy-build-only

    Summary:

    • deploy --build-only --output <dir> makes no login and no API call. It writes the bundle and a trigger-bundle.json manifest: CLI version, environment, build content hash, a hash of every bundle file and a config hash. Server env vars aren't fetched, so build extensions see only the process env and --env-file. The forced-externals list is the CLI's built-in one, and the deploy step checks it against the server's.
    • deploy --from <dir> (the public form of --from-bundle, which stays as the local-build alias) verifies the manifest and then uploads that exact bundle through the existing native fromBundle path. With --local-build it builds with local Docker. Either way it bundles nothing again.
    • --auth-method oidc accepts --from. The trusted prepare route can issue a deployment_bundle artifact, and submit accepts fromBundle with its contentHash. Caller-supplied build env vars stay refused.

    I tested --build-only end to end with no token, no stored login and an unreachable API URL. Two runs produced the same bundle hash.

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