Is `auto_inactive` supposed to work for successive deployments from the same branch?

I’m trying to figure out if I’m using deployment environments correctly, because auto_inactive doesn’t seem to be kicking in (previous non-transient deployments to the same environment are not being marked inactive) when I add a success deployment_status to an deployment.

I’ve chosen to use a 1:1 mapping between branch name and environment name. Is this perhaps confusing the auto_inactive logic? (The example from the 2016 announcement uses different branch names, so this seems to be a plausible reason to me).

This is what my flow looks like:

  • Create deployment [1] from branch foo in environment foo
  • Create in_progress status for deployment 1
  • Out-of-band: deploy branch to environment
  • Create success status for deployment 1
  • Push new changes to branch foo
  • Create deployment [2] from branch foo in environment foo
  • Create in_progress status for deployment 2
  • Out-of-band: deploy branch to environment
  • Create success status for deployment 2

At this point I would expect deployment 1 to be set inactive, but that does not seem to be happening.

If I look at the properties of the created deployments they are non-transient and non-production. So I’m not sure what other reason might be for the previous deployment not being updated to inactive.

Documentation references

Api docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos#create-a-deployment-status

auto_inactive: Adds a new inactive status to all prior non-transient, non-production environment deployments with the same repository and environment name as the created status’s deployment. An inactive status is only added to deployments that had a success state. Default: true

From https://developer.github.com/changes/2016-04-06-deployment-and-deployment-status-enhancements/#automatic-creation-of-inactive-statuses

Automatic creation of inactive statuses

Each time we receive a new successful deployment status, we automatically add a new inactive status to all previous deployments made within the relevant repository to the same environment (based on the value of environment) given the environment is both non-transient and non-production. You can opt out of this behavior by passing false with the new auto_inactive parameter.

For example, if feature-branch within https://github.com/user/repository is deployed to an environment named staging (which is a non-transient, non-production environment) and bugfix-branch within https://github.com/user/repository is later deployed to an environment named staging, we would automatically create a new inactive status for the deployment associated with feature-branch.

From https://developer.github.com/changes/2018-10-16-deployments-environments-states-and-auto-inactive-updates/#auto-inactive-status-now-available-in-production

Auto-inactive status now available in production

The auto_inactive parameter allows you to automatically add a new inactive status to all prior non-transient deployments with the same repository and environment name as the created status’s deployment. An inactive status is only added to deployments that have a success state. By default, auto_inactive is enabled.