Adds a public Env property to GitHubActionsAttribute - #417
Merged
ChrisonSimtian merged 6 commits intoJun 24, 2026
Merged
Conversation
…t-build#385) Adds a public `Env` property (entries in `KEY: value` form) to GitHubActionsAttribute, carried through GetConfiguration into GitHubActionsConfiguration and emitted once as a top-level `env:` block after `on:` and before `permissions:`. Variables declared this way are inherited by every job and step, including non-run steps (checkout, cache, artifact upload) that per-step env can't reach. Entries are validated at configuration-generation time: each must have a non-empty, whitespace-free key and a space after the colon, so a typo fails the build with a clear message instead of emitting malformed YAML. The property is additive (defaults to empty -> no `env:` block), so existing workflows generate byte-for-byte identical output. Covered by two Verify snapshots (env-only and env+permissions ordering) and a validation unit-test matrix.
avidenic
marked this pull request as ready for review
June 21, 2026 10:55
ChrisonSimtian
approved these changes
Jun 21, 2026
Contributor
Author
|
@ChrisonSimtian just a suggestion - this seems to be blocked every time a PR gets closed before this one even though there are no conflicting changes. Relaxing the rule that needs PR's branch always up to date might make things a bit smoother =) |
Collaborator
this goes away once your first contribution was merged :-) I've set this up intentional so that only contributors can run actions |
env: block
This was referenced Aug 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #385.
What
Adds a public
Envproperty toGitHubActionsAttribute(entries inKEY: valueform), emitted once as a top-levelenv:block in the generated workflow — afteron:and beforepermissions:— and inherited by every job and step, including non-run steps (checkout, cache, artifact upload) that per-step env can't reach.How
GitHubActionsAttribute.Env(string[], defaults to empty) → carried throughGetConfigurationinto a matchingGitHubActionsConfiguration.Env.GitHubActionsConfiguration.Writeemits the block only when non-empty, one indented entry per line, positioned afteron:and beforepermissions:/concurrency:/jobs:.KEY:) is allowed (valid empty value); colons inside the value are fine (first colon is the separator).Job- and step-level env are intentionally out of scope, as noted in the issue — they only become meaningful once multi-job/matrix workflows exist.
Backwards compatibility
Purely additive.
Envdefaults to empty, so existing[GitHubActions(...)]usages generate byte-for-byte identical YAML (noenv:block). Non-breaking →target/2026, nobreaking-change.Testing
Verifysnapshots inConfigurationGenerationTest:env-block(env → jobs) andenv-block-with-permissions(lockson: → env: → permissions: → concurrency: → jobs:ordering and spacing).GitHubActionsEnvValidationTest: validation matrix (null, empty, whitespace-only, no-colon, empty-key, whitespace-in-key, no-space-after-colon, multi-entry-with-bad-element; plus well-formed positives including a value containing a colon and an empty-value entry).dotnet fallout Test Packis green locally, including theNuke.*transition-shim test projects that consume this public API.Merge preference: (x) squash (default) ( ) rebase