Skip to content
Open
53 changes: 53 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,59 @@ A `Migration` section is added to any release that bumps `schema_version`.
exclusions, which existed only to mask this generator style, so the rule is
now enforced.

- **generate:** Promote's required-input validation is lane-aware: an operator
input a manifest declares under a deploy's `inputs:` counts as available
only on the matrix deploy job, the one promote job that threads it. The
prod deploy job, the rollback job, and the single-environment deploy path
call the same callback without operator inputs, and GitHub rejects a
reusable-workflow call that omits a required input (the same shape
actionlint's `[workflow-call]` check refuses), so a callback declaring an
operator input `required: true` fails generation with a message naming the
deploy, the input, and the lane(s) that omit it. The contract inputs
(`environment`, `sha`, `image_tag`, `image_digest`) remain available on
every lane, and a required input that is neither a contract input nor
manifest-declared still fails with the previous message, whose available
list now includes the manifest-declared inputs.

- **generate:** The hotfix workflow's `deploy-<name>` and `rollback-<name>` jobs
now thread the full deploy input surface to the configured deploy callback
instead of only the `environment`/`sha`/`dry_run` contract (#697). Operator
inputs (`inputs:`/`env_inputs:`) ride a one-entry matrix the context job
resolves at run time for the target environment (promote's
`DEFAULT_INPUTS`/`ENV_INPUTS` payload routed through step `env:`, with
`${{ state.* }}` references resolved at generation time as promote resolves
them and passthrough expressions such as `${{ vars.x }}` emitted verbatim);
the deploy lane threads `image_tag`/`image_digest` from the `depends_on`
builds' declared `workflow_call` outputs (`image_tag` and `artifact_id`);
and the rollback lane threads the N-1 refs the context job reads from
manifest state alongside the rollback SHA (`rollback_image_tag` from the
environment's recorded version, `rollback_image_digest` from the first
non-empty build `artifact_id`). The cascade-owned input names
(`environment`, `sha`, `dry_run`, `image_tag`, `image_digest`) always
thread with the lane's own value - an operator input carrying one of those
names is dropped rather than overriding the lane's - and values referencing
`${{ matrix.* }}` or `needs.<job>` (other than `context`), or a passthrough
with no `inputs:` default, are left out because no hotfix lane can resolve
them for the run-time target environment. Every line stays gated on the
inputs the callee declares, so a deploy declaring none of the new surface
generates byte-identical output. A deploy callback that declares a required
input a hotfix lane cannot supply now fails `cascade generate-workflow` -
the hotfix port of promote's required-input validation, evaluated per lane
(the deploy job and the rollback job both call the callback, so a required
input must be suppliable on each): `image_tag`/`image_digest` count as
supplied on the deploy lane only when a `depends_on` build declares the
matching output (`image_tag`, `artifact_id`), so a required image input with
no producing build fails with an error naming the deploy, the input, and
the deploy lane - the rollback lane's manifest-state reads alone do not
satisfy it. The matrix `include:` guards on `needs.context.result ==
'success'` and falls back to `[]`: the hotfix file carries both triggers,
the context job runs only on the merged-pull-request path, and a runner
that evaluates every job's `strategy` even on the dispatch path (act does,
before the `if:` gates) would otherwise feed `fromJSON` the skipped job's
unresolved output and die parsing the matrix; the fallback keeps that path
evaluable while the merged path - where the context job always succeeded -
threads the real one-entry matrix unchanged.

- **generate:** The hotfix workflow's `deploy-<name>` and `rollback-<name>` jobs
now invoke the configured deploy workflow instead of printing the deploy they
stand in for and succeeding (#678). Each deploy is a reusable-workflow call on
Expand Down
2 changes: 2 additions & 0 deletions docs/src/content/docs/guides/hotfix.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ The `plan` job fetches env branches and tags and runs `cascade hotfix plan`. The

Each hotfix deploy passes the callback contract's `environment` (the hotfix target), `sha` (the merge SHA, or the pre-hotfix SHA on the rollback lane), and `dry_run` inputs to your deploy workflow, each only when your workflow declares it. Declare the `environment:` key on the job inside your reusable workflow (see [the callback contract](/cascade/reference/callbacks/#environment-protection)) so the target environment's protection rules - manual approval on prod, for example - gate the hotfix deploy; GitHub Actions does not allow that key on the job cascade generates, because it calls your workflow with `uses:`.

Beyond the contract inputs, each hotfix deploy also threads the deploy's `inputs:` and `env_inputs:` - the entry for the resolved target environment is selected at run time by the context job, so the `env_inputs:` override keyed on the hotfix target is the one your callback receives - plus `image_tag` and `image_digest`: on the deploy lane they come from the `depends_on` builds' declared outputs, and on the rollback lane from the environment's recorded state (the last version and the first non-empty build digest). `${{ state.* }}` references inside those inputs resolve at generation time, exactly as promote resolves them. If your callback declares a required input, every hotfix lane that calls it must be able to supply it - the deploy job and the rollback job both do - or `cascade generate-workflow` fails and names the deploy, the input, and the lane; in particular `image_tag`/`image_digest` reach the deploy lane only from a `depends_on` build's declared outputs, so a callback requiring one needs such a build.

Finalize is rerun-safe. It records the diverged state on trunk, then creates the hotfix tag and release. If the run fails partway (for example the release API errors after the state commit), rerun the finalize job: the rerun completes the missing tag or release with the version already recorded, without double-applying state or allocating a new version.

## Environment branches and the stale-branch self-heal
Expand Down
6 changes: 4 additions & 2 deletions docs/src/content/docs/reference/generated-workflows.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,14 @@ Both carry two triggers in one file, and both drive the same deploy callbacks pr
| apply | `workflow_dispatch` (not dry-run) | Cherry-pick onto each environment bottom-up; opens a resolution pull request. |
| check | `pull_request` opened against `env/*` | Validate the manifest while the hotfix pull request is open. |
| build | merged hotfix pull request | Build the merge SHA (a cherry-pick has no prebuilt artifact). |
| deploy | merged hotfix pull request | Invoke the configured deploy callback on the merge SHA, threading the contract `environment`, `sha`, and `dry_run` inputs (each gated on the inputs the callback declares). Paired with a rollback job that re-invokes the same callback keyed on the pre-hotfix SHA when the deploy fails. |
| deploy | merged hotfix pull request | Invoke the configured deploy callback on the merge SHA, threading the contract `environment`, `sha`, and `dry_run` inputs plus the deploy's operator inputs, `image_tag`, and `image_digest` (each gated on the inputs the callback declares). Deploys with operator inputs fan out on a one-entry matrix the context job resolves for the target environment. Paired with a rollback job that re-invokes the same callback keyed on the pre-hotfix SHA - threading the N-1 image refs from manifest state - when the deploy fails. |
| finalize | deploy jobs succeed | Run `cascade hotfix finalize`: write the diverged state, tag, and release. |

Dispatch inputs: `commit` (one or more trunk fix SHAs), `target_env` (every configured environment except the first), `pr_number` (optional, to replay an existing resolution pull request), `dry_run`. The second trigger is `pull_request` on `types: [closed]` against `branches: ['env/*']`, gated on the pull request having merged with the `cascade-hotfix` label.

The deploy and rollback jobs are reusable-workflow (`uses:`) calls, so they cannot carry a job-level `environment:` key; the target environment is threaded as the `environment` input and protection rules apply through the `environment:` key your callback declares on its own job ([environment protection](/cascade/reference/callbacks/#environment-protection)). Operator-authored deploy inputs (`inputs:`/`env_inputs:`) are not threaded on the hotfix path: `env_inputs` key on a target environment the hotfix resolves at run time from the merged pull request's base ref, so there is no generation-time value to emit.
The deploy and rollback jobs are reusable-workflow (`uses:`) calls, so they cannot carry a job-level `environment:` key; the target environment is threaded as the `environment` input and protection rules apply through the `environment:` key your callback declares on its own job ([environment protection](/cascade/reference/callbacks/#environment-protection)).

Operator-authored deploy inputs (`inputs:`/`env_inputs:`) thread through a one-entry matrix the context job builds at run time for the resolved target environment, using the same serialized payload promote's preflight uses: the default inputs and per-environment overrides are baked into the workflow as `DEFAULT_INPUTS_<NAME>`/`ENV_INPUTS_<NAME>` JSON (routed through step `env:`), the context step merges the target environment's override with jq and appends the environment key, and the deploy and rollback jobs fan out on the single resulting entry, threading each input as `matrix.<key>`. The matrix `include:` guards on `needs.context.result == 'success'` and falls back to `[]`: the hotfix file carries both triggers, the context job runs only on the merged-pull-request path, and a runner that evaluates every job's strategy even on the dispatch path (act does, before the `if:` gates) would otherwise read the skipped job's unresolved output - so the fallback keeps that path evaluable while leaving the merged path, where the context job always succeeded, unchanged. `${{ state.* }}` references inside those inputs resolve at generation time, as promote's do; pure passthrough expressions (for example `${{ vars.x }}`) emit verbatim in `with:` instead of riding the matrix - only a passthrough declared as the `inputs:` default threads, since an `env_inputs:`-only passthrough has no generation-time value that is correct for the run-time-resolved target environment. Values referencing `${{ matrix.* }}` or `needs.<job>` (other than `context`) are left out: the hotfix matrix is synthetic and no lane can resolve them. The cascade-owned names (`environment`, `sha`, `dry_run`, `image_tag`, `image_digest`) are always threaded with the lane's own value, so an operator input carrying one of those names is dropped rather than overriding it. `image_tag`/`image_digest` come from the `depends_on` builds' declared `workflow_call` outputs on the deploy lane (omitted when no such build declares them), and from the target environment's manifest state on the rollback lane (`rollback_image_tag` is the recorded version, `rollback_image_digest` the first non-empty build `artifact_id`). `cascade generate-workflow` refuses a deploy callback whose required input any hotfix lane that calls it cannot supply, naming the deploy, the input, and the lane: the deploy lane threads `image_tag`/`image_digest` only from the `depends_on` builds' declared outputs, so a required image input with no producing build names the deploy lane - the rollback lane's state reads alone do not satisfy it.

### `cascade-rollback.yaml`

Expand Down
Loading