environment: rewrites the sub and moves the branch guard
- Problem
- A job needs environment: production to read that Environment's secrets, but this drops the branch from the sub, so the role condition can no longer pin a branch.
- Decision
- The role condition matches the environment:production form of the sub; the branch guard moves to Settings → Environments → production → Deployment branches in GitHub, where the production Environment is protected to allow only the main branch. As a result, the pipeline runs only when code is merged to main.
- Why
- GitHub blocks the job before it even requests the token if the run is not on main, so a build never even reaches AWS from any other branch. Keep in mind: the branch guard for this role now depends entirely on that Environment rule.