Skip to content

Resolve --gh-aw-ref branch/tag to commit SHA at compile time - #38689

Merged
dsyme merged 3 commits into
mainfrom
resolve-gh-aw-ref-to-sha
Jun 12, 2026
Merged

Resolve --gh-aw-ref branch/tag to commit SHA at compile time#38689
dsyme merged 3 commits into
mainfrom
resolve-gh-aw-ref-to-sha

Conversation

@dsyme

@dsymedsyme commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

PR #38689 — Resolve --gh-aw-ref branch/tag to commit SHA at compile time

Summary

Ensures that when a branch or tag name is supplied via --gh-aw-ref, it is resolved to a full 40-character immutable commit SHA at compile time (before the value is used as actionTag). Previously, a mutable ref such as a branch name could be embedded into the compiled workflow, making the resulting artifact non-deterministic. After this change the compiled output always pins to an exact SHA.


What changed

AreaFileChange
CLI entry-pointcmd/gh-aw/main.goCalls workflow.ResolveGhAwRef in the compile command handler; resolves the --gh-aw-ref value to a full SHA before it is stored as actionTag. Updates the flag's help text to reflect SHA resolution.
Workflow packagepkg/workflow/action_resolver.goNew exported function ResolveGhAwRef: queries the GitHub API for the given ref in the github/gh-aw repository and returns its full SHA. Short-circuits if the input is already a valid 40-char SHA (no API call needed).
DocumentationDEVGUIDE.mdClarifies that branch/tag names are resolved to an immutable commit SHA at compile time; updates the action reference format example from <REF> to <SHA>.

Motivation

Embedding a branch name (e.g. main) or a tag name into a compiled workflow means the reference can move between compile time and execution time, breaking reproducibility and auditability. Resolving to a SHA at compile time:

  • Guarantees the compiled artifact is fully pinned and reproducible.
  • Prevents silent drift if the upstream branch or tag is updated.
  • Aligns with supply-chain best practices for action references.

Behaviour details

  • Already-a-SHA fast path: ResolveGhAwRef checks whether the input is already a 40-hex-char SHA; if so it returns it immediately without making an API call.
  • GitHub API lookup: For any other value (branch name, tag name, short ref) the function calls the GitHub API against the github/gh-aw repository to resolve it.
  • No breaking changes: The flag interface is unchanged; only the internal representation of the resolved value differs (SHA instead of a possibly-mutable ref string).

Risk & impact

DimensionAssessment
Breaking changeNo
API calls addedOne GitHub API call per compile invocation when --gh-aw-ref is a non-SHA ref (zero calls if already a SHA)
Affected commandsgh aw compile only
Test surfacepkg/workflow/action_resolver.go (new exported function); cmd/gh-aw/main.go compile handler

Commits

SHAMessage
f1f2cccdaResolve --gh-aw-ref branch/tag to commit SHA at compile time
85a218061Merge branch 'main' into resolve-gh-aw-ref-to-sha
70b0f6124Potential fix for pull request finding

Generated by PR Description Updater for issue #38689 · 97.1 AIC · ⌖ 13.1 AIC · ⊞ 19.8K ·

CopilotAI review requested due to automatic review settings June 11, 2026 18:19

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request makes gh aw compile --gh-aw-ref <BRANCH|TAG> resolve the provided ref to an immutable 40-character commit SHA at compile time, preventing compiled .lock.yml files from silently drifting as branches move or tags are recreated.

Changes:

  • Added workflow.ResolveGhAwRef(ctx, ref) to resolve branch/tag refs to full commit SHAs (skipping resolution when already given a full SHA).
  • Updated the compile command’s --gh-aw-ref handling to resolve early and fail fast on resolution errors.
  • Updated DEVGUIDE.md and CLI flag help text to document SHA-resolution behavior.
Show a summary per file
FileDescription
pkg/workflow/action_resolver.goAdds ResolveGhAwRef to resolve github/gh-aw refs to full SHAs via gh api.
cmd/gh-aw/main.goUses ResolveGhAwRef when --gh-aw-ref is provided; updates help text accordingly.
DEVGUIDE.mdDocuments that branch/tag refs are resolved to SHAs at compile time for immutability.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 3/3 changed files
  • Comments generated: 3

Comment threadpkg/workflow/action_resolver.go
Comment threadpkg/workflow/action_resolver.go Outdated
Comment threadpkg/workflow/action_resolver.go
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

@copilot review all comments and address unresolved review feedback. Please refresh the branch and rerun checks once that is done.

Generated by 👨‍🍳 PR Sous Chef · 65.7 AIC · ⌖ 1.82 AIC · ⊞ 17.3K ·

@github-actions

Copy link
Copy Markdown
Contributor

@copilot review all comments and address unresolved review feedback.

Generated by 👨‍🍳 PR Sous Chef · 42.5 AIC · ⌖ 1.06 AIC · ⊞ 17.3K ·

@github-actions

Copy link
Copy Markdown
Contributor

Please rerun checks after the branch refresh and summarize any remaining blockers.

Generated by 👨‍🍳 PR Sous Chef · 42.5 AIC · ⌖ 1.06 AIC · ⊞ 17.3K ·

@github-actions

Copy link
Copy Markdown
Contributor

``
@copilot review all comments and address unresolved review feedback.

Generated by 👨‍🍳 PR Sous Chef · 28.5 AIC · ⌖ 1.01 AIC · ⊞ 17.3K ·

@github-actions

Copy link
Copy Markdown
Contributor

``
Please refresh the branch, re-run checks, and summarize any remaining blockers.

Generated by 👨‍🍳 PR Sous Chef · 28.5 AIC · ⌖ 1.01 AIC · ⊞ 17.3K ·

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@dsyme
dsyme merged commit 07acf6c into mainJun 12, 2026
20 of 21 checks passed
@dsyme
dsyme deleted the resolve-gh-aw-ref-to-sha branch June 12, 2026 03:57
@github-actions

Copy link
Copy Markdown
Contributor

✅ smoke-ci: safeoutputs CLI comment + comment-memory run (27393440896)

Generated by 🧪 Smoke CI for issue #38689 ·

@github-actionsgithub-actionsBot mentioned this pull request Jun 12, 2026
github-actionsBot added a commit that referenced this pull request Jun 12, 2026
…AwRef
Add missing Action Pinning entries introduced by #38689:
- NewActionResolver constructor
- ActionResolver.ResolveSHA method
- ResolveGhAwRef standalone function
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
github-actionsBot added a commit that referenced this pull request Jun 12, 2026
Documents two CLI gaps surfaced by daily activity:
- Adds `--gh-aw-ref` to the `compile` options list and a short
description explaining branch/tag SHA resolution (PR #38689).
- Corrects the `gh aw mcp add` inline comment to reflect that the
no-argument form lists registry servers, and adds a separate line
showing the add form (#38386 item 3).
Co-Authored-By: Claude Sonnet 4 <noreply@anthropic.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@dsyme