Add support for $GITHUB_ARTIFACTS environment files#4527
Draft
bdehamer wants to merge 1 commit into
Draft
Conversation
Signed-off-by: Brian DeHamer <bdehamer@github.com>
4930e1d to
9a64d83
Compare
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.
Summary
Adds support for two new per-job environment files that let workflow steps declare build artifacts and read back the aggregated set:
$GITHUB_ARTIFACTS(write side) — a step appends artifact references (local file paths or OCI subject references). The runner parses each entry, validates it, computes a digest for local files, and aggregates the results at job scope.$GITHUB_ARTIFACTS_LIST(read side) — the runner populates a JSON document enumerating every artifact subject declared so far in the job, so downstream steps can consume the canonical set.The feature is gated behind the
actions_runner_allow_artifacts_filefeature flag (with anACTIONS_RUNNER_ALLOW_ARTIFACTS_FILEenvironment-variable fallback) and is off by default.Changes
New files
CreateArtifactsFileCommand.cs— Write-side handler for$GITHUB_ARTIFACTS. Parses and validates each entry, computes SHA-256 digests for local files (resolved relative to the workspace root), and aggregates subjects at job scope with de-duplication, conflicting-digest detection, a 1 MiB file-size cap, and a 500-artifact aggregate cap.ArtifactsListFileCommand.cs— Read-side handler that populates$GITHUB_ARTIFACTS_LISTwith a versioned JSON document ({ version, subjects: [{ name, digest, kind }] }).ArtifactSubject.cs— Subject model (Name,Digest,Kind) shared by both commands.CreateArtifactsFileCommandL0.cs,ArtifactsListFileCommandL0.cs— Unit tests covering parsing, validation, digest computation, aggregation, de-dup/conflict handling, and list serialization.Modified files
FileCommandManager.cs— Adds aPopulateInitialContentshook (default no-op) so the list command can seed$GITHUB_ARTIFACTS_LISTbefore step execution; covered byFileCommandManagerL0.cs.ExtensionManager.cs— Registers the two new file commands.GlobalContext.cs/ExecutionContext.cs— Adds the job-scopedArtifactSubjectsaggregate, keyed by canonical subject name.GitHubContext.cs— Exposes theartifactsandartifacts_listcontext entries.Constants.cs— Adds theAllowArtifactsFilefeature flag and the artifact command error messages.Key design decisions
$GITHUB_ARTIFACTSare always resolved againstGITHUB_WORKSPACErather than a step'sworking-directory, matching the precedent set byhashFiles()and problem matchers.actions_runner_allow_artifacts_filewith an env-var fallback, so the behavior is opt-in until rollout.