fix: SHA-pin actions/setup in agentics-maintenance.yml generation#18378
fix: SHA-pin actions/setup in agentics-maintenance.yml generation#18378
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
… generation Pass an ActionResolver from the first available WorkflowData to ResolveSetupActionReference, enabling consistent SHA-pinned references (e.g., github/gh-aw/actions/setup@SHA # tag) in the generated agentics-maintenance.yml instead of tag-only references. Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
👋 Great work on this bug fix, The fix is clean: borrowing the shared
|
|
@copilot review code update and see if it is possible to refactor without having to create a mini workflow data. |
…etupActionReference Avoid creating a mini WorkflowData at call sites. The function now takes an *ActionResolver directly and creates the minimal WorkflowData internally only when SHA resolution is needed. Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Refactored in b29c1b5. // maintenance_workflow.go — no WorkflowData creation at call site
var resolver *ActionResolver
if len(workflowDataList) > 0 {
resolver = workflowDataList[0].ActionResolver
}
setupActionRef := ResolveSetupActionReference(actionMode, version, actionTag, resolver)
// action_reference.go — compiler passes data.ActionResolver
return ResolveSetupActionReference(c.actionMode, c.version, c.actionTag, resolver)Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
pkg/workflow/action_reference.go
Outdated
| if data != nil { | ||
| // If a resolver is available, try to resolve the SHA | ||
| if resolver != nil { | ||
| data := &WorkflowData{ |
There was a problem hiding this comment.
@copilot create dedicated go interface for this type
There was a problem hiding this comment.
Done in fd90936. Introduced ActionSHAResolver interface in action_resolver.go:
// ActionSHAResolver is the minimal interface for resolving an action tag to its commit SHA.
type ActionSHAResolver interface {
ResolveSHA(repo, version string) (string, error)
}ResolveSetupActionReference now accepts ActionSHAResolver and calls ResolveSHA directly — no WorkflowData is created anywhere in this path. *ActionResolver satisfies the interface without any changes.
…creation from ResolveSetupActionReference Define ActionSHAResolver interface with ResolveSHA() method. Change ResolveSetupActionReference to accept the interface instead of *ActionResolver. Call ResolveSHA directly inside the function — no WorkflowData is created at all. Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
There was a problem hiding this comment.
Pull request overview
Fixes missing SHA pinning for github/gh-aw/actions/setup in the generated agentics-maintenance.yml, aligning maintenance workflow generation with other action pinning behavior.
Changes:
- Introduces
ActionSHAResolverinterface and updatesResolveSetupActionReferenceto use it for SHA resolution. - Updates maintenance workflow generation to pass an action SHA resolver so
actions/setupcan be emitted as a SHA-pinneduses:reference. - Refreshes action pin/lock data (including
anchore/sbom-action@v0) and updates related tests.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/workflow/maintenance_workflow.go | Passes an action SHA resolver into setup action reference resolution during maintenance workflow generation. |
| pkg/workflow/maintenance_workflow_test.go | Adds coverage asserting SHA-pinned setup action ref in release mode when a resolver/cache is available. |
| pkg/workflow/action_resolver.go | Adds the ActionSHAResolver interface used by reference resolution code. |
| pkg/workflow/action_reference.go | Refactors setup action reference resolution to accept an interface and call ResolveSHA directly. |
| pkg/workflow/action_reference_test.go | Updates tests to use resolver interface rather than WorkflowData. |
| pkg/workflow/data/action_pins.json | Adds a pin entry for anchore/sbom-action@v0. |
| .github/aw/actions-lock.json | Syncs lock data with the new anchore/sbom-action@v0 pin. |
| .github/workflows/release.lock.yml | Updates anchore/sbom-action pinned SHA used by the release workflow. |
| .devcontainer/devcontainer.json | Reorders devcontainer feature entries (no functional change). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // - For release mode with resolver: "github/gh-aw/actions/setup@<sha> # <version>" (SHA-pinned) | ||
| // - For release mode without resolver: "github/gh-aw/actions/setup@<version>" (tag-based, SHA resolved later) | ||
| // - Falls back to local path if version is invalid in release mode |
There was a problem hiding this comment.
The docstring examples use “# ”, but this function passes the selected tag (actionTag override or version) to formatActionReference, so the comment will be “# ” (not necessarily the compiler version). Updating the comment/examples would avoid misleading callers when actionTag differs from version.
| // - For release mode with resolver: "github/gh-aw/actions/setup@<sha> # <version>" (SHA-pinned) | |
| // - For release mode without resolver: "github/gh-aw/actions/setup@<version>" (tag-based, SHA resolved later) | |
| // - Falls back to local path if version is invalid in release mode | |
| // - For release mode with resolver: "github/gh-aw/actions/setup@<sha> # <tag>" (SHA-pinned, where <tag> is actionTag or version) | |
| // - For release mode without resolver: "github/gh-aw/actions/setup@<tag>" (tag-based, SHA resolved later) | |
| // - Falls back to local path if tag is invalid (empty or "dev") in release mode |
| if len(workflowDataList) > 0 && workflowDataList[0].ActionResolver != nil { | ||
| resolver = workflowDataList[0].ActionResolver |
There was a problem hiding this comment.
The comment says this uses the “first available WorkflowData's ActionResolver”, but the code only checks workflowDataList[0] (and doesn’t guard against workflowDataList[0] being nil). This can miss a resolver provided by later entries or panic if the slice contains a nil element. Consider iterating until you find the first non-nil WorkflowData with a non-nil ActionResolver (or explicitly document that index 0 is required).
| if len(workflowDataList) > 0 && workflowDataList[0].ActionResolver != nil { | |
| resolver = workflowDataList[0].ActionResolver | |
| for _, wfData := range workflowDataList { | |
| if wfData != nil && wfData.ActionResolver != nil { | |
| resolver = wfData.ActionResolver | |
| break | |
| } |
* Initial plan * Initial plan Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> * fix: update TestGetActionPinsSorting count from 38 to 39 (actions/setup-go@v6 added) Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
maintenance_workflow.goto enable SHA pinning forgithub/gh-aw/actions/setupin the generatedagentics-maintenance.ymlActionSHAResolverinterface withResolveSHA(repo, version string) (string, error)inaction_resolver.goResolveSetupActionReferenceto acceptActionSHAResolverinstead of*ActionResolver— callsResolveSHAdirectly, noWorkflowDatacreated anywhereaction_reference.goandmaintenance_workflow.goto use the interface type (with nil-safety for the concrete-pointer-to-interface pitfall)action_reference_test.gomake fmt lintand targeted unit testsOriginal prompt
gh aw compileconsistent actions/setup sha generation #18373🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.