in codecatalyst-runner/pkg/workflows/workflow_plans_provider.go [260:290]
func loadRemoteAction(ctx context.Context, actionID string) (*actions.Action, error) {
if actionVersion, ok := ActionVersions[actionID]; !ok {
return nil, fmt.Errorf("unknown actions %s", actionID)
} else {
actionsURL := fmt.Sprintf(ActionsUrlTemplate, actionID, actionVersion)
log.Ctx(ctx).Info().Msgf("🚚 downloading action %s", actionID)
sha := sha256.Sum256([]byte(actionsURL))
actionsURLHash := hex.EncodeToString(sha[:])
cacheDir, err := os.UserCacheDir()
if err != nil {
return nil, err
}
actionDir := filepath.Join(cacheDir, "codecatalyst-runner", "actions", actionsURLHash)
if err := os.RemoveAll(actionDir); err != nil {
return nil, fmt.Errorf("unable to cleanup actionDir %s: %w", actionDir, err)
}
if err := downloadHttpExtractZip(ctx, actionsURL, actionDir); err != nil {
return nil, fmt.Errorf("unable to download actionsUrl %s: %w", actionsURL, err)
}
if entries, err := os.ReadDir(actionDir); err != nil {
return nil, fmt.Errorf("unable to list actionDir %s: %w", actionDir, err)
} else {
for _, entry := range entries {
if entry.IsDir() && strings.HasPrefix(entry.Name(), "cloned-repo-") {
actionDir = filepath.Join(actionDir, entry.Name())
}
}
}
return actions.Load(actionDir)
}
}