convertToExternalActionsRef converts a local action path to a SHA-pinned (if possible) reference in the external github/gh-aw-actions repository. Example: "./actions/create-issue" -> "github/gh-aw-actions/create-issue@ # v1.0.0" If SHA resolution fails (no resolver or pin not available), falls
(localPath string, data *WorkflowData)
| 263 | // If SHA resolution fails (no resolver or pin not available), falls back to version-tagged reference: |
| 264 | // Example: "./actions/create-issue" -> "github/gh-aw-actions/create-issue@v1.0.0" |
| 265 | func (c *Compiler) convertToExternalActionsRef(localPath string, data *WorkflowData) string { |
| 266 | // Strip the leading "./" prefix |
| 267 | actionPath := strings.TrimPrefix(localPath, "./") |
| 268 | |
| 269 | // Strip the "actions/" prefix to get just the action name |
| 270 | // e.g., "actions/create-issue" -> "create-issue" |
| 271 | actionName := strings.TrimPrefix(actionPath, "actions/") |
| 272 | |
| 273 | // Determine tag: use compiler actionTag or version |
| 274 | tag := c.actionTag |
| 275 | if tag == "" { |
| 276 | if data != nil && data.Features != nil { |
| 277 | if actionTagVal, exists := data.Features["action-tag"]; exists { |
| 278 | if actionTagStr, ok := actionTagVal.(string); ok && actionTagStr != "" { |
| 279 | tag = actionTagStr |
| 280 | } |
| 281 | } |
| 282 | } |
| 283 | } |
| 284 | if tag == "" { |
| 285 | tag = c.version |
| 286 | if tag == "" || tag == "dev" { |
| 287 | actionRefLog.Print("WARNING: No release tag available in binary version (version is 'dev' or empty)") |
| 288 | return "" |
| 289 | } |
| 290 | } |
| 291 | |
| 292 | // Construct the external actions reference: <actionsRepo>/action-name@tag |
| 293 | actionRepo := fmt.Sprintf("%s/%s", c.effectiveActionsRepo(), actionName) |
| 294 | remoteRef := fmt.Sprintf("%s@%s", actionRepo, tag) |
| 295 | |
| 296 | // Try to resolve the SHA using action pins |
| 297 | if data != nil { |
| 298 | pinnedRef, err := getActionPinWithData(actionRepo, tag, data) |
| 299 | if err != nil { |
| 300 | // Log and fall through to tag-based reference (action mode is not strict) |
| 301 | actionRefLog.Printf("Failed to pin action %s@%s: %v, falling back to tag-based reference", actionRepo, tag, err) |
| 302 | } else if pinnedRef != "" { |
| 303 | actionRefLog.Printf("Action mode: resolved %s to SHA-pinned reference: %s", remoteRef, pinnedRef) |
| 304 | return pinnedRef |
| 305 | } |
| 306 | } |
| 307 | |
| 308 | // If SHA resolution unavailable or pin not found, return tag-based reference |
| 309 | actionRefLog.Printf("Action mode: using tag-based external actions repo reference: %s (SHA will be resolved later)", remoteRef) |
| 310 | return remoteRef |
| 311 | } |
no test coverage detected