Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

GitHub Environments & Promotion Pipeline#5664

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
73dward5 wants to merge3 commits intoAzure:main
base:main
Choose a base branch
Loading
fromedwards-itj:73dward5/feat-5329-github-env

Conversation

@73dward5
Copy link

@73dward573dward5 commentedAug 28, 2025
edited
Loading

GitHub Environments Opt-In & Force Regeneration

Overview

This adds optional flags toazd pipeline config to allow pushing environment variables/secrets to the GitHub environment instead of the repo level variables/secrets and federating the identity with that environment instead of the branch or PR.

Adds:

  • --github-use-environments to generate a GitHub Actions workflow using GitHub Environments (single or matrix when multiple azd envs).
  • --force-regenerate to overwrite the existing workflow unconditionally.

Also: migration heuristics, federated credential pruning, repo variable cleanup, updated snapshots, lint/spelling fixes.

Key Changes

  • Flags:--github-use-environments,--force-regenerate
  • Workflow template: conditional matrix,max-parallel: 1, secret/variable validation
  • Auto-regeneration when env-mode mismatch detected
  • Prunes legacy federated credentials (branch / PR subjects) for SP & MSI
  • Removes redundant repo-level variables after migration
  • Manager helpers:EnableGitHubEnvironments,ForceRegenerateWorkflow
  • Snapshot & usage/help updates
  • Typo fix:progessprogress
  • Allgolangci-lint issues resolved

Behavior & Migration

ScenarioResult
Legacy workflow + opt-inRegenerates with env matrix (if >1 env)
Env workflow + opt-outRegenerates to legacy single
Any state +--force-regenerateAlways rewrites

Pruning Scope

Only deletes federated credentials with:pull_request or:ref:refs/heads/ (keeps:environment: subjects).

Testing

  • Short tests pass
  • Updated snapshots pass
  • Functional failures unrelated (local env missing .NET 8, expired Azure auth token)
  • Lint: clean

Risks & Mitigations

RiskMitigation
Unexpected overwriteRequires explicit flag or mismatch
Over-pruningFilters to known legacy subjects
Env var API limitationsHeuristic delete for known migrated names

Follow-Ups

  • Docs for env vs legacy mode
  • Release notes entry
  • (Optional) cspell dictionary tuning

Checklist

  • Flags
  • Template logic
  • Migration + pruning
  • Tests & snapshots
  • Lint/spelling
  • Docs
  • Release notes

Release Notes Blurb

Adds opt-in GitHub Environments workflow generation (--github-use-environments) and--force-regenerate to forcibly recreate workflows, with automatic migration and cleanup of

… flag; env-scoped cleanup & workflow matrix updates
… flag; env-scoped cleanup & workflow matrix updates
@73dward5
Copy link
Author

  • [5664] GitHub pipeline config: supports setting secrets & variables in a GitHub Environment named after the current azd environment (automatically created if needed) and adds a matching OIDC federated credential subject (repo:<owner>/<repo>:environment:<AZURE_ENV_NAME>). (Previously configurable viaAZD_GITHUB_ENV; that variable is now ignored.) Fixes#5473.
  • [5664] Added optional--github-use-environments flag toazd pipeline config to emit GitHub Environment (and matrix when multiple) blocks. Disabled by default; existing workflows remain unchanged unless flag is provided. Re-running with the flag toggled will migrate the existing workflow by adding or removing the environment/matrix section. Addresses matrix & multi‑environment ask in#2373 and community feedback indiscussion #3585.
  • [5664] Environment mode now migrates standard AZD pipeline variables to the GitHub Environment scope (removing repo-level duplicates) and generates only the environment federated credential subject. Related to#5473.
  • [5664] Automatic pruning of legacy branch & pull_request federated identity credentials when switching to environment-only mode (service principal & MSI identities). Part of cleanup for#5473.

@73dward5
Copy link
Author

@microsoft-github-policy-service agree

@73dward5
Copy link
Author

I am fine with this PR being rejected, as long as you can derive some benefit from the code to implement GitHub environments.

@weikanglim
Copy link
Contributor

weikanglim commentedAug 28, 2025
edited
Loading

Thanks@73dward5 for taking the time to submit this PR!

I do like inspirationally where this is going, and this does help illuminate certain design details upfront for some work we have in the backlog with#5329.

I'm curious to learn from your experience:

  1. How was your experience withazd pipeline config looping through all environments?azd pipeline config traditionally targets a single environment. I could see a different implementation whereazd pipeline config makes a YAML modification to the environment matrix, instead of regenerating it from scratch. But this may also introduce other potential drawbacks, cc:@vhvb1989 .
  2. Was the generated matrix (run environment deployments in parallel) "good enough" for your use-case, or were you expecting some idea of promotion between environments, with perhaps a build stage that spawns deployment jobs?
  3. Was it a good experience when usingAZURE_ENV_NAME as the github environment name? This has come up in discussions in the past, because azd currently expectsAZURE_ENV_NAME to be unique per subscription, so you may end up having something closer likemyproject-dev rather thandev.

Thanks for taking the time to get this PR out and sharing your experience!

@73dward5
Copy link
Author

73dward5 commentedSep 1, 2025
edited
Loading

  1. How was your experience with azd pipeline config looping through all environments? azd pipeline config traditionally targets a single environment. I could see a different implementation where azd pipeline config makes a YAML modification to the environment matrix, instead of regenerating it from scratch. But this may also introduce other potential drawbacks, cc:@vhvb1989 .
  • Having one pipeline for all environments does a couple of things. One, it helps keep the pipeline code DRY and free from duplication or misconfiguration between environments. Secondly, it allows for the environments to be promotable without having to orchestrate the environment promotions with separate pipelines. Or a branching strategy that ends up being closer to your deployment strategy, rather than staying true to your branching and contribution model.
  1. Was the generated matrix (run environment deployments in parallel) "good enough" for your use-case, or were you expecting some idea of promotion between environments, with perhaps a build stage that spawns deployment jobs?
  • The generated matrix works well as long as themax-parallel is1, ensuring the environments do in fact stay promotable (e.g.Dev finishes, thenTest, thenProd) instead of trying to run them all at the same time. In theory, the build should only need to run once before the deployment. However, it can be more challenging for some languages/tools to separate the environment variables from the build artifacts. For example, Terraform would need the tfvars for the plan, or a Node.js SPA might need the environment variables to be in the js. Other languages, like .NET, can be built, and then environment variables can be injected on the server (during the deployment) after the artifact is created.
  1. Was it a good experience when using AZURE_ENV_NAME as the github environment name? This has come up in discussions in the past, because azd currently expects AZURE_ENV_NAME to be unique per subscription, so you may end up having something closer like myproject-dev rather than dev.
  • I thinkAZURE_ENV_NAME as the github environment name works great to provide your current environment working context locally, but if you are building a promotable pipeline, you may want to know about all of your environments. In my opinion, if you are publishing a pipeline, you are essentially moving the build/deploy responsibility to CI/CD and no longer managing that process from your local machine. I do think that allowing custom environment names like myproject-dev rather than dev does contribute to developer flexibility and autonomy. With that flexibility, you do sort of run into some complexities in programmatically determining the promotion order, though.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@wbrezawbrezaAwaiting requested review from wbrezawbreza is a code owner

@vhvb1989vhvb1989Awaiting requested review from vhvb1989vhvb1989 is a code owner

@hemarinahemarinaAwaiting requested review from hemarinahemarina is a code owner

@weikanglimweikanglimAwaiting requested review from weikanglimweikanglim is a code owner

@JeffreyCAJeffreyCAAwaiting requested review from JeffreyCAJeffreyCA is a code owner

@tg-msfttg-msftAwaiting requested review from tg-msfttg-msft is a code owner

@rajeshkamal5050rajeshkamal5050Awaiting requested review from rajeshkamal5050rajeshkamal5050 is a code owner

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

customer-reportedidentify a customer issue

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@73dward5@weikanglim

[8]ページ先頭

©2009-2025 Movatter.jp