mirror of
https://gitea.com/gitea/act_runner.git
synced 2026-03-22 06:45:03 +01:00
feat: allow configuring gitea schema mode (#23)
* config entries for schema change * remove broken/unused syntetic nodejs action * specify desired schema in model struct that is read by unmarshal * replace params by config * allows gitea context + env names * act --gitea now parses a subset of gitea specific workflows Reviewed-on: https://gitea.com/actions-oss/act-cli/pulls/23 Co-authored-by: Christopher Homberger <christopher.homberger@web.de> Co-committed-by: Christopher Homberger <christopher.homberger@web.de>
This commit is contained in:
committed by
ChristopherHX
parent
faa252c8e9
commit
933c4a5bd5
@@ -83,13 +83,29 @@ type Action struct {
|
||||
Color string `yaml:"color"`
|
||||
Icon string `yaml:"icon"`
|
||||
} `yaml:"branding"`
|
||||
Definition string `yaml:"-"`
|
||||
Schema *schema.Schema `yaml:"-"`
|
||||
}
|
||||
|
||||
func (a *Action) GetDefinition() string {
|
||||
if a.Definition == "" {
|
||||
return "action-root"
|
||||
}
|
||||
return a.Definition
|
||||
}
|
||||
|
||||
func (a *Action) GetSchema() *schema.Schema {
|
||||
if a.Schema == nil {
|
||||
return schema.GetActionSchema()
|
||||
}
|
||||
return a.Schema
|
||||
}
|
||||
|
||||
func (a *Action) UnmarshalYAML(node *yaml.Node) error {
|
||||
// Validate the schema before deserializing it into our model
|
||||
if err := (&schema.Node{
|
||||
Definition: "action-root",
|
||||
Schema: schema.GetActionSchema(),
|
||||
Definition: a.GetDefinition(),
|
||||
Schema: a.GetSchema(),
|
||||
}).UnmarshalYAML(node); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -110,9 +126,16 @@ type Output struct {
|
||||
Value string `yaml:"value"`
|
||||
}
|
||||
|
||||
type ActionConfig struct {
|
||||
Definition string
|
||||
Schema *schema.Schema
|
||||
}
|
||||
|
||||
// ReadAction reads an action from a reader
|
||||
func ReadAction(in io.Reader) (*Action, error) {
|
||||
func ReadAction(in io.Reader, config ActionConfig) (*Action, error) {
|
||||
a := new(Action)
|
||||
a.Schema = config.Schema
|
||||
a.Definition = config.Definition
|
||||
err := yaml.NewDecoder(in).Decode(a)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user