Skip to content

Let forks run CI in a shared subscription and keep CI environments with a tag - #5272

Merged
Jay W (JayDoubleu) merged 3 commits into
microsoft:mainfrom
JayDoubleu:feature/ci-fork-isolation-and-keep-tag
Oct 21, 2026
Merged

Jay W (JayDoubleu) merged 3 commits into
microsoft:mainfrom
JayDoubleu:feature/ci-fork-isolation-and-keep-tag

Conversation

@JayDoubleu

@JayDoubleu Jay W (JayDoubleu) commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

What is being addressed

Many organisations may use Azure TRE as an accelerator. They might copy this repository into their own repository, which becomes their internal upstream. Their developers then work in forks of that copy and open PRs into it. Often, the copy and its forks run CI in the same Azure subscription.

This setup does not work well today:

  • Each repository gives its PR and branch CI environments the same names, so the environments collide.
  • The scheduled cleanup in one repository can stop or destroy the environments of another repository.
  • A team cannot keep a CI environment, for example for a demo or to debug a failure. Scheduled cleanup destroys it.

How is this addressed

  • Add an optional CI_ENV_PREFIX repository variable for the names of CI environments, and a ci_repository tag on the CI groups. Cleanup, explicit destruction and bootstrap lease recovery act only on groups with the prefix that the repository owns.
  • Add the ci_keep_until tag (a date or forever). Scheduled cleanup does not stop or destroy an environment that has the tag.
  • Document both in docs/tre-admins/setup-instructions/workflows.md and docs/tre-developers/github-pr-bot-commands.md.
  • Update CHANGELOG.md and increment the core, devops and build-scripts versions.

No change for this repository

This repository does not need any new variable, secret or manual step:

  • Without CI_ENV_PREFIX, microsoft/AzureTRE uses the default prefix tre. CI environment names stay the same as before.
  • Existing CI groups without the ci_repository tag still belong to this repository. Cleanup and /test-destroy-env find them as before.
  • Main deployments do not change.

The new behaviour applies only to a repository that sets CI_ENV_PREFIX, or to an environment that has the ci_keep_until tag.

This repository can also use the keep tag. For example, a maintainer can keep a PR environment for a demo, or to debug a failed E2E test without a new deployment. Nothing changes until someone adds the tag to an environment.

Tests

  • We tested the change end to end in a copy of this repository and in a fork of that copy, in one shared subscription. The tests included main, PR and fork PR deployments, and scheduled cleanup with and without the keep tag.
  • Unit tests cover the path without CI_ENV_PREFIX. For PR and branch references, the old and the new code give the same environment names.

…th a tag

Add the CI_ENV_PREFIX repository variable and a ci_repository tag, so
that a fork can run PR and branch CI in a subscription that it shares
with this repository. Cleanup, explicit destruction and bootstrap lease
recovery act only on groups with the prefix that the repository owns.

Add the ci_keep_until tag. Scheduled cleanup does not stop or destroy
a CI environment that has the tag on its core or management group.
@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Unit Test Results

0 tests   0 ✅  0s ⏱️
0 suites  0 💤
0 files    0 ❌

Results for commit dece11e.

♻️ This comment has been updated with latest results.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Case-sensitive ownership-tag lookups can permit takeover or deletion of another repository’s CI environment.

3 open issues
1 file not reviewed
  • .github/scripts/package-lock.json: Generated file
What changed in this PR

Adds repository-scoped CI environments to support Azure TRE forks sharing a subscription, plus tags to retain environments during scheduled cleanup.

Changes:

  • Adds configurable CI prefixes and repository ownership checks.
  • Adds ci_keep_until protection against scheduled stopping and destruction.
  • Expands tests and documentation, and updates component versions.
File Description
docs/​tre-developers/​github-pr-bot-commands.md Documents destruction scope and keep-tag behavior.
docs/​tre-admins/​setup-instructions/​workflows.md Explains fork configuration and environment retention.
devops/​version.txt Bumps DevOps version.
devops/​tests/​test_validate_ci_cleanup.py Covers fork validation lifecycle.
devops/​tests/​test_recover_bootstrap_lease.py Tests recovery ownership checks.
devops/​tests/​test_destroy_ci_ref_env.py Tests scoped explicit destruction.
devops/​tests/​test_clean_ci_validation_envs.py Tests cleanup ownership and retention.
devops/​tests/​test_ci_environment_id.py Tests prefixes and ownership rules.
devops/​tests/​test_ci_cleanup_scope.py Tests cleanup scope and keep tags.
devops/​tests/​test_bootstrap_ci_tags.py Tests bootstrap ownership tagging.
devops/​tests/​README.md Adds fork validation prerequisites.
devops/​terraform/​variables.tf Defines repository ownership input.
devops/​terraform/​main.tf Applies management ownership tags.
devops/​terraform/​locals.tf Combines CI ownership tags.
devops/​terraform/​bootstrap.sh Checks ownership before management-group updates.
devops/​scripts/​validate_ci_cleanup.py Adapts validation to configured prefixes.
devops/​scripts/​recover_bootstrap_lease.py Scopes recovery by prefix and owner.
devops/​scripts/​destroy_ci_ref_env.py Checks repository ownership before destruction.
devops/​scripts/​clean_ci_validation_envs.sh Filters cleanup and honors keep decisions.
devops/​scripts/​ci_environment_id.py Adds prefix and ownership helpers.
devops/​scripts/​ci_cleanup_scope.py Adds scoped planning and retention checks.
devops/​bootstrap-lease-recovery.md Documents ownership-aware recovery.
core/​version.txt Bumps core version.
core/​terraform/​variables.tf Defines core repository input.
core/​terraform/​main.tf Adds core ownership tag.
CHANGELOG.md Records isolation and retention features.
.github/​workflows/​pr_comment_bot.yml Routes prefixed deployment and destruction.
.github/​workflows/​deploy_tre_reusable.yml Passes prefix and repository metadata.
.github/​workflows/​deploy_tre_branch.yml Generates prefixed branch environment names.
.github/​workflows/​clean_validation_envs.yml Passes cleanup prefix configuration.
.github/​scripts/​package.json Bumps build-scripts version.
.github/​scripts/​package-lock.json Synchronizes version metadata.
.github/​scripts/​ci_environment_workflow.test.js Tests workflow naming and metadata propagation.
.github/​actions/​devcontainer_run_command/​action.yml Forwards ownership metadata into containers.

Review effort: Balanced

Comment thread devops/scripts/ci_environment_id.py Outdated
Comment thread devops/scripts/clean_ci_validation_envs.sh Outdated
Comment thread devops/terraform/bootstrap.sh Outdated
Azure tag names are not case-sensitive, and Azure returns the case that
created the tag. Ownership checks in cleanup, explicit destruction,
bootstrap and lease recovery read ci_repository and ci_git_ref
case-sensitively, so a tag written as CI_Repository looked untagged.
Read these tags with lowercase names through one helper, and refuse tag
names that differ only in case.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Destructive shared-subscription cleanup and lease recovery warrant maintainer confirmation of the reported live isolation and retention validation.

No open issues 🎉

3 resolved since last review
1 file not reviewed
  • .github/scripts/package-lock.json: Generated file

Review effort: Balanced

@JayDoubleu

Copy link
Copy Markdown
Collaborator Author

/test

@JayDoubleu
Jay W (JayDoubleu) marked this pull request as ready for review October 21, 2026 14:04
@JayDoubleu
Jay W (JayDoubleu) requested a review from a team as a code owner October 21, 2026 14:04
@github-actions

Copy link
Copy Markdown

🤖 pr-bot 🤖

🏃 Running tests: https://github.com/microsoft/AzureTRE/actions/runs/39613580177

(in response to this comment from Jay W (@JayDoubleu))

@marrobi Marcus Robinson (marrobi) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Providing it doesn't break anything, LGTM!

@JayDoubleu
Jay W (JayDoubleu) merged commit d0151a4 into microsoft:main Oct 21, 2026
6 checks passed
@JayDoubleu
Jay W (JayDoubleu) deleted the feature/ci-fork-isolation-and-keep-tag branch October 21, 2026 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants