Skip to content

Add "action" mode for github/gh-aw-actions external actions repo#20776

Merged
pelikhan merged 7 commits intomainfrom
copilot/add-action-pin-mode
Mar 13, 2026
Merged

Add "action" mode for github/gh-aw-actions external actions repo#20776
pelikhan merged 7 commits intomainfrom
copilot/add-action-pin-mode

Conversation

Copy link
Contributor

Copilot AI commented Mar 13, 2026

Adds a new action pin mode that references github/gh-aw-actions/setup and github/gh-aw-actions/setup-cli at the same release version — a separate repository from the existing release mode which SHA-pins within github/gh-aw.

Changes

  • action_mode.go: New ActionModeAction = "action" constant, IsAction() predicate, IsValid() updated
  • action_reference.go: New GitHubActionsOrgRepo = "github/gh-aw-actions" constant; ResolveSetupActionReference() handles action mode with SHA pinning via resolver (falls back to version-tag if unavailable); new convertToExternalActionsRef() converts any local ./actions/<name> path to a SHA-pinned github/gh-aw-actions/<name>@<sha> # <version> reference when possible, falling back to github/gh-aw-actions/<name>@<version> gracefully
  • maintenance_workflow.go: generateInstallCLISteps() uses github/gh-aw-actions/setup-cli@<version> in action mode
  • copilot_setup.go:
    • getActionRef() attempts SHA resolution for github/gh-aw-actions/setup-cli in action mode (falls back to version-tag)
    • generateCopilotSetupStepsYAML() uses a single shared template for both release and action modes, varying only the action repo path
    • renderCopilotSetupUpdateInstructions() correctly shows action-mode instructions
    • ensureCopilotSetupStepsWithUpgrade() creates a SHA resolver for both release and action modes
    • upgradeSetupCliVersionInContent() handles action mode upgrades using github/gh-aw-actions/setup-cli; setupCliUsesPattern updated to match both github/gh-aw/actions/setup-cli and github/gh-aw-actions/setup-cli
  • compile_compiler_setup.go: Validation error updated to list 'action' as a valid option

Behavior at a glance

Mode setup reference SHA pinned Checkout needed
dev ./actions/setup (local)
release github/gh-aw/actions/setup@<sha> # <version>
action github/gh-aw-actions/setup@<sha> # <version> (or @<version> if SHA unavailable) if possible

Usage:

gh aw compile --action-mode action workflow.md
Original prompt

Add a new action pin mode "action" that resolves to using the github/gh-aw-actions/setup (and setup-cli) custom actions (same release number)


📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.



✨ PR Review Safe Output Test - Run 23051296351

💥 [THE END] — Illustrated by Smoke Claude ·

Copilot AI and others added 2 commits March 13, 2026 06:21
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Add new action pin mode for github actions Add "action" mode for github/gh-aw-actions external actions repo Mar 13, 2026
Copilot AI requested a review from pelikhan March 13, 2026 06:37
@pelikhan
Copy link
Contributor

@copilot the "action" mode should also sha pin if possible.

// Determine the action reference - use SHA-pinned or version tag in release mode, @main in dev mode
actionRef := getActionRef(actionMode, version, resolver)

if actionMode.IsAction() {
Copy link
Contributor

Choose a reason for hiding this comment

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

@copilot reuse the same template, just update the action being used. See line 73

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in cb0eb57. generateCopilotSetupStepsYAML now uses a single template for both release and action modes — only the action repo path (github/gh-aw/actions/setup-cli vs github/gh-aw-actions/setup-cli) differs. Also fixed renderCopilotSetupUpdateInstructions which was incorrectly falling through to the curl command for action mode.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 13, 2026

@copilot the "action" mode should also sha pin if possible.

Done in f7e5821. Action mode now attempts SHA pinning via the resolver (same as release mode):

  • ResolveSetupActionReference(): tries resolver.ResolveSHA("github/gh-aw-actions/setup", tag) — falls back to version-tag if unavailable
  • convertToExternalActionsRef(): tries GetActionPinWithData for all action paths in the external repo — falls back to version-tag gracefully (never returns empty on pin failure)
  • getActionRef() in copilot_setup.go: tries resolver.ResolveSHA("github/gh-aw-actions/setup-cli", version) — falls back to version-tag

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:

  • https://api.github.com/repos/github/gh-aw-actions/git/ref/tags/v1.0.0
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v1.0.0 --jq .object.sha (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v1.0.0 --jq .object.sha -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE node (http block)
  • https://api.github.com/repos/github/gh-aw-actions/git/ref/tags/v1.2.3
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v1.2.3 --jq .object.sha pare.go mat.go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v1.2.3 --jq .object.sha INVALID,NEW -j DROP GOINSECURE GOMOD GOMODCACHE o fix.&#34;; \ exitGO111MODULE env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE node (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v1.0.0
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.0.0 --jq .object.sha (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.0.0 --jq .object.sha 0 -j ACCEPT GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE node (http block)

If you need me to access, download, or install something from one of these locations, you can either:

@pelikhan
Copy link
Contributor

@copilot also add support for codepath that adds the setup-cli action (same logic)

…ease and action modes

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 13, 2026

@copilot also add support for codepath that adds the setup-cli action (same logic)

Done in 4f1fb1b. Changes to the upgrade codepath:

  • ensureCopilotSetupStepsWithUpgrade: SHA resolver is now created for both IsRelease() and IsAction() modes
  • setupCliUsesPattern: Updated regex now matches both github/gh-aw/actions/setup-cli and github/gh-aw-actions/setup-cli
  • upgradeSetupCliVersionInContent: Now handles action mode (previously bailed out for non-release), using github/gh-aw-actions/setup-cli as the action repo path

@pelikhan pelikhan marked this pull request as ready for review March 13, 2026 13:06
Copilot AI review requested due to automatic review settings March 13, 2026 13:06
@pelikhan pelikhan merged commit 2794315 into main Mar 13, 2026
4 checks passed
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new action pin mode that references custom actions from the github/gh-aw-actions external repository instead of the existing github/gh-aw/actions/ path, with SHA pinning when possible and graceful fallback to version tags.

Changes:

  • New ActionModeAction constant with IsAction() predicate and updated validation across action_mode.go, compile_compiler_setup.go
  • action_reference.go and copilot_setup.go updated to resolve setup/setup-cli references to github/gh-aw-actions/ repo with SHA pinning support
  • maintenance_workflow.go generates install steps using the external actions repo in action mode

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pkg/workflow/action_mode.go Adds ActionModeAction constant, IsAction() method, updates IsValid()
pkg/workflow/action_reference.go Adds GitHubActionsOrgRepo constant, action mode handling in ResolveSetupActionReference and new convertToExternalActionsRef
pkg/workflow/maintenance_workflow.go Action mode branch in generateInstallCLISteps
pkg/cli/copilot_setup.go Action mode support in getActionRef, YAML generation, upgrade logic, and regex pattern
pkg/cli/compile_compiler_setup.go Updated error message to include 'action'
pkg/workflow/compiler_custom_actions_test.go Tests for action mode validation, compilation, and reference resolution

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

You can also share your feedback on Copilot code review. Take the survey.

// and quoted refs produced by some YAML marshalers (e.g. "...@sha # vX.Y.Z").
var setupCliUsesPattern = regexp.MustCompile(
`(?m)^(\s+uses:[ \t]*)"?(github/gh-aw/actions/setup-cli@[^"\n]*)"?([ \t]*)$`)
`(?m)^(\s+uses:[ \t]*)"?(github/gh-aw(?:-actions)?/(?:actions/)?setup-cli@[^"\n]*)"?([ \t]*)$`)
@pelikhan pelikhan deleted the copilot/add-action-pin-mode branch March 13, 2026 13:08
Sign up for free to 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.

3 participants