courgette/internal/actions/act.go

28 lines
677 B
Go
Raw Normal View History

// Implementation for basic Action-related operations.
package actions
import (
2024-09-02 16:28:23 +00:00
"fmt"
"strings"
)
// Returns a key that can be used as a directory / cache-key string
// based on the provided Action repository url.
func GetActionKey(url string) string {
url = strings.ToLower(url)
if strings.HasPrefix(url, "http://") {
url = strings.TrimPrefix(url, "http://")
} else if strings.HasPrefix(url, "https://") {
url = strings.TrimPrefix(url, "https://")
}
parts := strings.Split(url, "/")
return strings.Join(parts, "__")
}
2024-09-02 16:28:23 +00:00
func FormatInputEnvKey(inputKey string) string {
return fmt.Sprintf("INPUT_%s", strings.ReplaceAll(strings.ToUpper(inputKey), " ", "_"))
}