mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2025-08-11 17:50:58 +00:00
local actions
Signed-off-by: Casey Lee <cplee@nektos.com>
This commit is contained in:
parent
770966a7d0
commit
7f5ced76f6
6 changed files with 319 additions and 137 deletions
|
@ -3,6 +3,7 @@ package model
|
|||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"gopkg.in/yaml.v2"
|
||||
|
@ -63,11 +64,41 @@ func (s *Step) GetEnv() map[string]string {
|
|||
}
|
||||
for k, v := range s.With {
|
||||
envKey := fmt.Sprintf("INPUT_%s", strings.ToUpper(k))
|
||||
envKey = regexp.MustCompile("[^A-Z0-9]").ReplaceAllString(envKey, "_")
|
||||
rtnEnv[envKey] = v
|
||||
}
|
||||
return rtnEnv
|
||||
}
|
||||
|
||||
// StepType describes what type of step we are about to run
|
||||
type StepType int
|
||||
|
||||
const (
|
||||
// StepTypeRun is all steps that have a `run` attribute
|
||||
StepTypeRun StepType = iota
|
||||
|
||||
//StepTypeUsesDockerURL is all steps that have a `uses` that is of the form `docker://...`
|
||||
StepTypeUsesDockerURL
|
||||
|
||||
//StepTypeUsesActionLocal is all steps that have a `uses` that is a reference to a github repo
|
||||
StepTypeUsesActionLocal
|
||||
|
||||
//StepTypeUsesActionRemote is all steps that have a `uses` that is a local action in a subdirectory
|
||||
StepTypeUsesActionRemote
|
||||
)
|
||||
|
||||
// Type returns the type of the step
|
||||
func (s *Step) Type() StepType {
|
||||
if s.Run != "" {
|
||||
return StepTypeRun
|
||||
} else if strings.HasPrefix(s.Uses, "docker://") {
|
||||
return StepTypeUsesDockerURL
|
||||
} else if strings.HasPrefix(s.Uses, "./") {
|
||||
return StepTypeUsesActionLocal
|
||||
}
|
||||
return StepTypeUsesActionRemote
|
||||
}
|
||||
|
||||
// ReadWorkflow returns a list of jobs for a given workflow file reader
|
||||
func ReadWorkflow(in io.Reader) (*Workflow, error) {
|
||||
w := new(Workflow)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue