feat: add dollar-self action reference syntax#4457
Draft
nodeselector wants to merge 7 commits into
Draft
Conversation
Implement support for the $/ self-referencing syntax in the actions runner. This syntax resolves to 'this repo, at this SHA' based on the containing YAML file, allowing composite actions to reference sibling actions in the same repository without hardcoding versions. Key changes: - Parse $/path as RepositoryPathReference with RepositoryType='dollar-self' - Resolve dollar-self refs in ActionManager before download: - Depth 0 (workflow level): github.repository + github.sha - Depth > 0 (composite): parent action's Name + Ref - After resolution, refs flow through existing remote action infrastructure - Pre/post steps supported (unlike ./path local refs) - Feature-flagged via actions_dollar_self_reference Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
In PrepareActionsRecursiveAsync (the batch resolution path), nested composite sub-steps with $/ references were passed to ResolveNewActionsAsync before their dollar-self refs had been resolved. GetDownloadInfoLookupKey throws InvalidOperationException for unresolved DollarSelfAlias, crashing the batch path. Fix: pre-compute parent context per group and call ResolveDollarSelfReferences on each group BEFORE ResolveNewActionsAsync. The existing ResolveDollarSelfReferences call at the top of the recursive function becomes a no-op for already-resolved refs. The legacy path (PrepareActionsRecursiveLegacyAsync) was not affected because it recurses directly per-action without a batch pre-resolve step. Tests added: - Nested composite with $/ (batch path) - Nested composite with $/ (legacy path) - Cross-repo composite: $/ resolves to parent repo, not root - Three-level $/ chain (a→b→c)
$/ is platform-agnostic YAML syntax, not a filesystem path. Remove the $\\ StartsWith checks and TrimStart backslash handling from both PipelineTemplateConverter and WorkflowTemplateConverter.
…eference Extract the $/ prefix detection + path extraction into a single static helper. Both PipelineTemplateConverter and WorkflowTemplateConverter now use it instead of inline StartsWith/Substring logic.
The previous message said "This is a runner bug" — misleading when the actual cause is the actions_dollar_self_reference feature flag not being enabled. Now names the flag explicitly.
LoadAction re-parses action.yml from disk each time it is called, producing fresh ActionStep objects with raw dollar-self refs. The setup-time resolution in PrepareActionsRecursiveAsync operates on a different set of objects, so the runtime composite steps still had unresolved $/ refs — causing NullReferenceException when CompositeActionHandler tried to use repoAction.Name (which is null for dollar-self refs). Fix: after loading composite steps in LoadAction, call ResolveDollarSelfReferences using the parent action's Name and Ref. This covers Steps, PreSteps, and PostSteps.
For reusable workflows, github.repository/sha point to the caller repo, not the reusable workflow repo. job.workflow_repository/workflow_sha point to the repo containing the workflow file — correct for both regular and reusable workflows. Fall back to github context when JobContext is unavailable.
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.
$/— dollar-self action reference syntaxAdds
$/pathas a newuses:syntax meaning "this repo, at this SHA, at the given subpath." The containing YAML file determines which repo and SHA — so$/lib/helperinsideexternal/foo@v1resolves toexternal/foo@v1with pathlib/helper, not the workflow's root repo.Why
Composite actions that ship multiple sub-actions in one repo currently hardcode
owner/repo@refto reference siblings. This creates a circular versioning problem — you can't cut a release tag until the YAML already references that tag.$/breaks the cycle: siblings reference each other by path, and the ref is inherited from the caller.What changed
Parsing —
PipelineTemplateConverterandWorkflowTemplateConverterdetect$/via a sharedPipelineConstants.TryParseDollarSelfReference()helper. The parsed reference getsRepositoryType = "dollar-self"andPath = <subpath>.Resolution —
ActionManager.ResolveDollarSelfReferences()rewritesdollar-selfrefs to concreteGitHubrefs in-place:github.repository+github.shaName+RefAfter resolution, refs flow through the existing remote action download/prepare infrastructure. Pre/post steps work (unlike
./pathlocal refs).Batch path fix —
PrepareActionsRecursiveAsync(the batch resolution path) had a bug: nested composite sub-steps with$/were passed toResolveNewActionsAsyncbefore dollar-self resolution, causingGetDownloadInfoLookupKeyto throwInvalidOperationException. Fixed by pre-computing parent context per group and resolving$/before the batch API call. The legacy path was not affected.Feature flag
Gated behind
actions_dollar_self_reference. When the flag is off,$/references hitGetDownloadInfoLookupKeywhich throws with a clear error message. No silent misbehavior, no impact on existing workflows.Tests
6 tests covering dollar-self resolution:
$/)$/(batch path)$/(legacy path)$/resolves to parent repo, not root$/chain (a→b→c)Files
Constants.csDollarSelfReferencefeature flagPipelineConstants.csDollarSelfAlias,DollarSelfPrefix,TryParseDollarSelfReference()WorkflowConstants.csDollarSelfAliasPipelineTemplateConverter.cs$/parsing via shared helperWorkflowTemplateConverter.cs$/detection for step ID generationActionManager.csResolveDollarSelfReferences(), batch path fixActionManagerL0.cs