Repository navigation
Keep SHA pins in same-repo composite actions - #298
Merged
Merged
Conversation
Building on the sub-path guard, restrict RewriteActionRefs, ValidateRequiredActionRefRewrites and UsesValues to step-level uses: values using walkUses' position rules. An action-shaped uses: key under with: is input data and was still rewritten and counted. Refs #261
A full-SHA uses: inside a same-repository $/ action is no longer rewritten to the tag it resolves to. Other repositories run that action without this lockfile, so the SHA is the only pin they get. The ref is still locked, under its SHA spelling, in every workflow that reaches it. Fixes #264
The lockfile records a renamed repository under its new name, so a full-SHA uses: in a $/ action must follow the rename to stay covered. The rename keeps the SHA.
A workflow that uses a renamed repository's new name at the commit a same-repository action pins under the old name could narrow the shared dependency to a tag and carry that tag into the action file with the rename.
There was a problem hiding this comment.
🟡 Changes recommended
UsesValues can miss aliased step dependencies, allowing a still-used root to be removed and causing --verify-local to report ref-changed.
1 open issue
What changed in this PR
Addresses #264 by preserving SHA pins in same-repository composite actions, protecting external consumers that do not have the action repository’s lockfile.
Changes:
- Keep full-SHA refs locked for every calling workflow without
sha-as-refwarnings. - Preserve SHAs across repository renames and restrict rewrites to step-level
uses:. - Update documentation and regression coverage.
| File | Description |
|---|---|
README.md |
Documents the composite-action SHA exemption. |
internal/workflowfile/workflowfile.go |
Adds node-aware traversal of step references. |
internal/workflowfile/rewrite.go |
Limits rewriting, validation, and inventory to step references. |
internal/workflowfile/rewrite_test.go |
Tests exclusion of workflow calls and input data. |
internal/pipeline/parse.go |
Excludes composite-action SHA pins from narrowing. |
internal/pipeline/parse_test.go |
Tests filtering rules and the non-nil empty subset. |
internal/pipeline/checks/structural.go |
Suppresses warnings for exempt SHA pins. |
internal/pipeline/checks/run_test.go |
Tests the warning exemption. |
internal/pin/plan.go |
Keeps exempt references eligible for repository rename updates. |
docs/troubleshooting.md |
Explains the SHA warning exemption. |
cmd/gh-actions-lock/selfrepository_test.go |
Tests SHA preservation and repository renames. |
cmd/gh-actions-lock/run_test.go |
Tests SHA coverage across workflows sharing an action. |
cmd/gh-actions-lock/command_test.go |
Tests that reusable workflow calls retain their SHA. |
Review effort: Max (adaptive)
| steps := stepUsesNodes(&f.root) | ||
| walkYAMLNodes(&f.root, func(keyNode, valueNode *yaml.Node) { | ||
| if keyNode != nil && valueNode != nil && keyNode.Value == "uses" && valueNode.Kind == yaml.ScalarNode { | ||
| if keyNode != nil && valueNode != nil && keyNode.Value == "uses" && valueNode.Kind == yaml.ScalarNode && steps[valueNode] { |
3 tasks done
3 tasks done
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.

Fixes #264
$/…composite action is no longer rewritten to a tag. Other repos that use the action don't have your lockfile, so the SHA is the only pin they get.sha-as-refwarning anymore.uses:values get rewritten now. Job-level reusable workflow calls anduseskeys underwith:are left alone.$/…actions (tags, branches) are still narrowed like before.