[Bug] `hydrogen deploy`: `--env` and `--env-branch` are mutually exclusive
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 2.1k
- Forks
- 443
- Avg merge
- 4d 19h
- Merged PRs (30d)
- 24
Description
What is the location of your example repository?
https://github.com/Shopify/hydrogen/tree/main/templates/skeleton
Which package or tool is having this issue?
CLI
What version of that package or tool are you using?
@shopify/cli-hydrogen@11.1.16 & @shopify/cli@4.0.0
What version of React Router 7 are you using?
7.14.0
Steps to Reproduce
-
In Oxygen Admin, create a long-lived environment, e.g.
stagingwith branch tagstaging, exposed at a stable URL (e.g.https://staging-skeleton.hydrogen.shop/). -
Locally, check out a different branch (e.g. a weekly release branch
release/1.2.3):git checkout release/1.2.3 -
Try to deploy that working tree to the
stagingenvironment:shopify hydrogen deploy --env staging --env-branch release/1.2.3The CLI rejects this:
--env-branch=release/1.2.3 cannot also be provided when using --env -
Drop
--env-branchand use only--env:shopify hydrogen deploy --env stagingThe deploy is forced to the environment's configured branch (
staging); there is no way to deploy therelease/1.2.3working tree under thestagingenvironment while preserving traceability of the source branch. -
Drop
--envand use only the deprecated flag:shopify hydrogen deploy --env-branch stagingThis flag is deprecated, and in CI (
CI=1) it is also the only option, since--envis rejected withCan't specify an environment handle in CI.
Expected Behavior
Concretely, any of the following would resolve the gap:
- Allow
--envand--env-branchto be combined.--envselects the environment record (URL, secrets, env vars);--env-branchoverrides the deployment tag. Both should work in interactive and CI modes. - Replace the deprecated
--env-branchwith a clearly-named successor (e.g.--deployment-tag) that composes with--env. - Allow
--envalone to deploy the working tree against the chosen environment, without coupling the deployment tag to the environment's configured branch.
This would unblock release-train workflows where a team: - cuts a
release/X.Y.Zbranch on a regular cadence, - needs to QA each release at a fixed staging URL backed by stable secrets/env vars,
- and wants the deployment tag in Oxygen Admin to reflect the actual source branch (
release/1.2.3), not a generic placeholder.
The same flag combination must work in CI, since releases are typically deployed from automation rather than a developer's laptop.
Actual Behavior
There is no flag combination that lets a developer deploy an arbitrary local branch to a chosen environment handle:
--env <handle> --env-branch <tag>→ rejected byexclusive: ['env-branch']inpackages/cli/src/lib/flags.ts.--env <handle>alone → the deployment tag is taken from the environment's configured branch in Admin, ignoring the local checkout. There is no opt-out.--env-branch <tag>alone → works, but the flag is deprecated (--env-branch is deprecated. Use --env instead.) and is the only option allowed in CI today.
The result is a forced choice between (a) reconfiguring the staging environment's branch in Oxygen Admin for every release, (b) renaming branches to match a fixed tag and losing release identity, or (c) relying on a deprecated flag with no announced successor that covers this case.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in packages/cli/src/lib/flags.ts, where the exclusive env-branch validation is mentioned, and reproduce the deploy commands with and without CI=1. Trace how the environment handle and deployment tag are passed through the CLI. Done means a chosen environment can be deployed with an explicit source tag in both interactive and CI modes without relying on the deprecated flag.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100