mirror of
https://gitea.com/gitea/act_runner.git
synced 2026-03-20 20:06:16 +08:00
fix: Allow almost all node<number> variants in actions.runs (#120)
This commit is contained in:
@@ -20,28 +20,34 @@ func (a *ActionRunsUsing) UnmarshalYAML(unmarshal func(interface{}) error) error
|
||||
|
||||
// Force input to lowercase for case insensitive comparison
|
||||
format := ActionRunsUsing(strings.ToLower(using))
|
||||
switch format {
|
||||
case ActionRunsUsingNode20, ActionRunsUsingNode16, ActionRunsUsingNode12, ActionRunsUsingDocker, ActionRunsUsingComposite:
|
||||
switch {
|
||||
case format.IsNode() || format.IsDocker() || format.IsComposite():
|
||||
*a = format
|
||||
default:
|
||||
return fmt.Errorf("the runs.using key in action.yml must be one of: %v, got %s", []string{
|
||||
ActionRunsUsingComposite,
|
||||
ActionRunsUsingDocker,
|
||||
ActionRunsUsingNode12,
|
||||
ActionRunsUsingNode16,
|
||||
ActionRunsUsingNode20,
|
||||
ActionRunsUsingNode + "<node version like 12, 16, 20, 24 or later>",
|
||||
}, format)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a ActionRunsUsing) IsNode() bool {
|
||||
return strings.HasPrefix(string(a), string(ActionRunsUsingNode))
|
||||
}
|
||||
|
||||
func (a ActionRunsUsing) IsDocker() bool {
|
||||
return a == ActionRunsUsingDocker
|
||||
}
|
||||
|
||||
func (a ActionRunsUsing) IsComposite() bool {
|
||||
return a == ActionRunsUsingComposite
|
||||
}
|
||||
|
||||
const (
|
||||
// ActionRunsUsingNode12 for running with node12
|
||||
ActionRunsUsingNode12 = "node12"
|
||||
// ActionRunsUsingNode16 for running with node16
|
||||
ActionRunsUsingNode16 = "node16"
|
||||
// ActionRunsUsingNode20 for running with node20
|
||||
ActionRunsUsingNode20 = "node20"
|
||||
// ActionRunsUsingNode for running with node12, node16, node20, node24 or later
|
||||
ActionRunsUsingNode = "node"
|
||||
// ActionRunsUsingDocker for running with docker
|
||||
ActionRunsUsingDocker = "docker"
|
||||
// ActionRunsUsingComposite for running composite
|
||||
|
||||
Reference in New Issue
Block a user