mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2025-08-11 17:50:58 +00:00
Merge tag 'nektos/v0.2.46'
This commit is contained in:
commit
b6b329d4b5
9 changed files with 166 additions and 52 deletions
4
.github/workflows/checks.yml
vendored
4
.github/workflows/checks.yml
vendored
|
@ -26,7 +26,7 @@ jobs:
|
||||||
- uses: golangci/golangci-lint-action@v3.4.0
|
- uses: golangci/golangci-lint-action@v3.4.0
|
||||||
with:
|
with:
|
||||||
version: v1.47.2
|
version: v1.47.2
|
||||||
- uses: megalinter/megalinter/flavors/go@v6.22.2
|
- uses: megalinter/megalinter/flavors/go@v7.0.2
|
||||||
env:
|
env:
|
||||||
DEFAULT_BRANCH: master
|
DEFAULT_BRANCH: master
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
@ -61,7 +61,7 @@ jobs:
|
||||||
- name: Run act from cli
|
- name: Run act from cli
|
||||||
run: go run main.go -P ubuntu-latest=node:16-buster-slim -C ./pkg/runner/testdata/ -W ./basic/push.yml
|
run: go run main.go -P ubuntu-latest=node:16-buster-slim -C ./pkg/runner/testdata/ -W ./basic/push.yml
|
||||||
- name: Upload Codecov report
|
- name: Upload Codecov report
|
||||||
uses: codecov/codecov-action@v3.1.3
|
uses: codecov/codecov-action@v3.1.4
|
||||||
with:
|
with:
|
||||||
files: coverage.txt
|
files: coverage.txt
|
||||||
fail_ci_if_error: true # optional (default = false)
|
fail_ci_if_error: true # optional (default = false)
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/docker/distribution/reference"
|
"github.com/docker/distribution/reference"
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
|
@ -59,6 +60,13 @@ func NewDockerPullExecutor(input NewDockerPullExecutorInput) common.Executor {
|
||||||
|
|
||||||
_ = logDockerResponse(logger, reader, err != nil)
|
_ = logDockerResponse(logger, reader, err != nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if imagePullOptions.RegistryAuth != "" && strings.Contains(err.Error(), "unauthorized") {
|
||||||
|
logger.Errorf("pulling image '%v' (%s) failed with credentials %s retrying without them, please check for stale docker config files", imageRef, input.Platform, err.Error())
|
||||||
|
imagePullOptions.RegistryAuth = ""
|
||||||
|
reader, err = cli.ImagePull(ctx, imageRef, imagePullOptions)
|
||||||
|
|
||||||
|
_ = logDockerResponse(logger, reader, err != nil)
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -69,9 +77,9 @@ func getImagePullOptions(ctx context.Context, input NewDockerPullExecutorInput)
|
||||||
imagePullOptions := types.ImagePullOptions{
|
imagePullOptions := types.ImagePullOptions{
|
||||||
Platform: input.Platform,
|
Platform: input.Platform,
|
||||||
}
|
}
|
||||||
|
logger := common.Logger(ctx)
|
||||||
|
|
||||||
if input.Username != "" && input.Password != "" {
|
if input.Username != "" && input.Password != "" {
|
||||||
logger := common.Logger(ctx)
|
|
||||||
logger.Debugf("using authentication for docker pull")
|
logger.Debugf("using authentication for docker pull")
|
||||||
|
|
||||||
authConfig := types.AuthConfig{
|
authConfig := types.AuthConfig{
|
||||||
|
@ -93,6 +101,7 @@ func getImagePullOptions(ctx context.Context, input NewDockerPullExecutorInput)
|
||||||
if authConfig.Username == "" && authConfig.Password == "" {
|
if authConfig.Username == "" && authConfig.Password == "" {
|
||||||
return imagePullOptions, nil
|
return imagePullOptions, nil
|
||||||
}
|
}
|
||||||
|
logger.Info("using DockerAuthConfig authentication for docker pull")
|
||||||
|
|
||||||
encodedJSON, err := json.Marshal(authConfig)
|
encodedJSON, err := json.Marshal(authConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -263,8 +263,8 @@ func RunnerArch(ctx context.Context) string {
|
||||||
|
|
||||||
archMapper := map[string]string{
|
archMapper := map[string]string{
|
||||||
"x86_64": "X64",
|
"x86_64": "X64",
|
||||||
"386": "x86",
|
"386": "X86",
|
||||||
"aarch64": "arm64",
|
"aarch64": "ARM64",
|
||||||
}
|
}
|
||||||
if arch, ok := archMapper[info.Architecture]; ok {
|
if arch, ok := archMapper[info.Architecture]; ok {
|
||||||
return arch
|
return arch
|
||||||
|
|
|
@ -368,7 +368,11 @@ func (e *HostEnvironment) ToContainerPath(path string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *HostEnvironment) GetActPath() string {
|
func (e *HostEnvironment) GetActPath() string {
|
||||||
return e.ActPath
|
actPath := e.ActPath
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
actPath = strings.ReplaceAll(actPath, "\\", "/")
|
||||||
|
}
|
||||||
|
return actPath
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*HostEnvironment) GetPathVariableName() string {
|
func (*HostEnvironment) GetPathVariableName() string {
|
||||||
|
@ -389,11 +393,13 @@ func (*HostEnvironment) JoinPathVariable(paths ...string) string {
|
||||||
return strings.Join(paths, string(filepath.ListSeparator))
|
return strings.Join(paths, string(filepath.ListSeparator))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reference for Arch values for runner.arch
|
||||||
|
// https://docs.github.com/en/actions/learn-github-actions/contexts#runner-context
|
||||||
func goArchToActionArch(arch string) string {
|
func goArchToActionArch(arch string) string {
|
||||||
archMapper := map[string]string{
|
archMapper := map[string]string{
|
||||||
"x86_64": "X64",
|
"x86_64": "X64",
|
||||||
"386": "x86",
|
"386": "X86",
|
||||||
"aarch64": "arm64",
|
"aarch64": "ARM64",
|
||||||
}
|
}
|
||||||
if arch, ok := archMapper[arch]; ok {
|
if arch, ok := archMapper[arch]; ok {
|
||||||
return arch
|
return arch
|
||||||
|
|
|
@ -160,67 +160,117 @@ func (ee expressionEvaluator) evaluate(ctx context.Context, in string, defaultSt
|
||||||
return evaluated, err
|
return evaluated, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ee expressionEvaluator) evaluateScalarYamlNode(ctx context.Context, node *yaml.Node) error {
|
func (ee expressionEvaluator) evaluateScalarYamlNode(ctx context.Context, node *yaml.Node) (*yaml.Node, error) {
|
||||||
var in string
|
var in string
|
||||||
if err := node.Decode(&in); err != nil {
|
if err := node.Decode(&in); err != nil {
|
||||||
return err
|
return nil, err
|
||||||
}
|
}
|
||||||
if !strings.Contains(in, "${{") || !strings.Contains(in, "}}") {
|
if !strings.Contains(in, "${{") || !strings.Contains(in, "}}") {
|
||||||
return nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
expr, _ := rewriteSubExpression(ctx, in, false)
|
expr, _ := rewriteSubExpression(ctx, in, false)
|
||||||
res, err := ee.evaluate(ctx, expr, exprparser.DefaultStatusCheckNone)
|
res, err := ee.evaluate(ctx, expr, exprparser.DefaultStatusCheckNone)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return nil, err
|
||||||
}
|
}
|
||||||
return node.Encode(res)
|
ret := &yaml.Node{}
|
||||||
|
if err := ret.Encode(res); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return ret, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ee expressionEvaluator) evaluateMappingYamlNode(ctx context.Context, node *yaml.Node) error {
|
func (ee expressionEvaluator) evaluateMappingYamlNode(ctx context.Context, node *yaml.Node) (*yaml.Node, error) {
|
||||||
|
var ret *yaml.Node = nil
|
||||||
// GitHub has this undocumented feature to merge maps, called insert directive
|
// GitHub has this undocumented feature to merge maps, called insert directive
|
||||||
insertDirective := regexp.MustCompile(`\${{\s*insert\s*}}`)
|
insertDirective := regexp.MustCompile(`\${{\s*insert\s*}}`)
|
||||||
for i := 0; i < len(node.Content)/2; {
|
for i := 0; i < len(node.Content)/2; i++ {
|
||||||
|
changed := func() error {
|
||||||
|
if ret == nil {
|
||||||
|
ret = &yaml.Node{}
|
||||||
|
if err := ret.Encode(node); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
ret.Content = ret.Content[:i*2]
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
k := node.Content[i*2]
|
k := node.Content[i*2]
|
||||||
v := node.Content[i*2+1]
|
v := node.Content[i*2+1]
|
||||||
if err := ee.EvaluateYamlNode(ctx, v); err != nil {
|
ev, err := ee.evaluateYamlNodeInternal(ctx, v)
|
||||||
return err
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if ev != nil {
|
||||||
|
if err := changed(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ev = v
|
||||||
}
|
}
|
||||||
var sk string
|
var sk string
|
||||||
// Merge the nested map of the insert directive
|
// Merge the nested map of the insert directive
|
||||||
if k.Decode(&sk) == nil && insertDirective.MatchString(sk) {
|
if k.Decode(&sk) == nil && insertDirective.MatchString(sk) {
|
||||||
node.Content = append(append(node.Content[:i*2], v.Content...), node.Content[(i+1)*2:]...)
|
if ev.Kind != yaml.MappingNode {
|
||||||
i += len(v.Content) / 2
|
return nil, fmt.Errorf("failed to insert node %v into mapping %v unexpected type %v expected MappingNode", ev, node, ev.Kind)
|
||||||
} else {
|
}
|
||||||
if err := ee.EvaluateYamlNode(ctx, k); err != nil {
|
if err := changed(); err != nil {
|
||||||
return err
|
return nil, err
|
||||||
|
}
|
||||||
|
ret.Content = append(ret.Content, ev.Content...)
|
||||||
|
} else {
|
||||||
|
ek, err := ee.evaluateYamlNodeInternal(ctx, k)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if ek != nil {
|
||||||
|
if err := changed(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ek = k
|
||||||
|
}
|
||||||
|
if ret != nil {
|
||||||
|
ret.Content = append(ret.Content, ek, ev)
|
||||||
}
|
}
|
||||||
i++
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ee expressionEvaluator) evaluateSequenceYamlNode(ctx context.Context, node *yaml.Node) error {
|
func (ee expressionEvaluator) evaluateSequenceYamlNode(ctx context.Context, node *yaml.Node) (*yaml.Node, error) {
|
||||||
for i := 0; i < len(node.Content); {
|
var ret *yaml.Node = nil
|
||||||
|
for i := 0; i < len(node.Content); i++ {
|
||||||
v := node.Content[i]
|
v := node.Content[i]
|
||||||
// Preserve nested sequences
|
// Preserve nested sequences
|
||||||
wasseq := v.Kind == yaml.SequenceNode
|
wasseq := v.Kind == yaml.SequenceNode
|
||||||
if err := ee.EvaluateYamlNode(ctx, v); err != nil {
|
ev, err := ee.evaluateYamlNodeInternal(ctx, v)
|
||||||
return err
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
}
|
}
|
||||||
// GitHub has this undocumented feature to merge sequences / arrays
|
if ev != nil {
|
||||||
// We have a nested sequence via evaluation, merge the arrays
|
if ret == nil {
|
||||||
if v.Kind == yaml.SequenceNode && !wasseq {
|
ret = &yaml.Node{}
|
||||||
node.Content = append(append(node.Content[:i], v.Content...), node.Content[i+1:]...)
|
if err := ret.Encode(node); err != nil {
|
||||||
i += len(v.Content)
|
return nil, err
|
||||||
} else {
|
}
|
||||||
i++
|
ret.Content = ret.Content[:i]
|
||||||
|
}
|
||||||
|
// GitHub has this undocumented feature to merge sequences / arrays
|
||||||
|
// We have a nested sequence via evaluation, merge the arrays
|
||||||
|
if ev.Kind == yaml.SequenceNode && !wasseq {
|
||||||
|
ret.Content = append(ret.Content, ev.Content...)
|
||||||
|
} else {
|
||||||
|
ret.Content = append(ret.Content, ev)
|
||||||
|
}
|
||||||
|
} else if ret != nil {
|
||||||
|
ret.Content = append(ret.Content, v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ee expressionEvaluator) EvaluateYamlNode(ctx context.Context, node *yaml.Node) error {
|
func (ee expressionEvaluator) evaluateYamlNodeInternal(ctx context.Context, node *yaml.Node) (*yaml.Node, error) {
|
||||||
switch node.Kind {
|
switch node.Kind {
|
||||||
case yaml.ScalarNode:
|
case yaml.ScalarNode:
|
||||||
return ee.evaluateScalarYamlNode(ctx, node)
|
return ee.evaluateScalarYamlNode(ctx, node)
|
||||||
|
@ -229,10 +279,21 @@ func (ee expressionEvaluator) EvaluateYamlNode(ctx context.Context, node *yaml.N
|
||||||
case yaml.SequenceNode:
|
case yaml.SequenceNode:
|
||||||
return ee.evaluateSequenceYamlNode(ctx, node)
|
return ee.evaluateSequenceYamlNode(ctx, node)
|
||||||
default:
|
default:
|
||||||
return nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ee expressionEvaluator) EvaluateYamlNode(ctx context.Context, node *yaml.Node) error {
|
||||||
|
ret, err := ee.evaluateYamlNodeInternal(ctx, node)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if ret != nil {
|
||||||
|
return ret.Decode(node)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (ee expressionEvaluator) Interpolate(ctx context.Context, in string) string {
|
func (ee expressionEvaluator) Interpolate(ctx context.Context, in string) string {
|
||||||
if !strings.Contains(in, "${{") || !strings.Contains(in, "}}") {
|
if !strings.Contains(in, "${{") || !strings.Contains(in, "}}") {
|
||||||
return in
|
return in
|
||||||
|
|
|
@ -58,9 +58,12 @@ func newRemoteReusableWorkflowExecutor(rc *RunContext) common.Executor {
|
||||||
if remoteReusableWorkflow == nil {
|
if remoteReusableWorkflow == nil {
|
||||||
return common.NewErrorExecutor(fmt.Errorf("expected format {owner}/{repo}/.{git_platform}/workflows/{filename}@{ref}. Actual '%s' Input string was not in a correct format", uses))
|
return common.NewErrorExecutor(fmt.Errorf("expected format {owner}/{repo}/.{git_platform}/workflows/{filename}@{ref}. Actual '%s' Input string was not in a correct format", uses))
|
||||||
}
|
}
|
||||||
remoteReusableWorkflow.URL = rc.Config.GitHubInstance
|
|
||||||
|
|
||||||
workflowDir := fmt.Sprintf("%s/%s", rc.ActionCacheDir(), safeFilename(uses))
|
// uses with safe filename makes the target directory look something like this {owner}-{repo}-.github-workflows-{filename}@{ref}
|
||||||
|
// instead we will just use {owner}-{repo}@{ref} as our target directory. This should also improve performance when we are using
|
||||||
|
// multiple reusable workflows from the same repository and ref since for each workflow we won't have to clone it again
|
||||||
|
filename := fmt.Sprintf("%s/%s@%s", remoteReusableWorkflow.Org, remoteReusableWorkflow.Repo, remoteReusableWorkflow.Ref)
|
||||||
|
workflowDir := fmt.Sprintf("%s/%s", rc.ActionCacheDir(), safeFilename(filename))
|
||||||
|
|
||||||
// FIXME: if the reusable workflow is from a private repository, we need to provide a token to access the repository.
|
// FIXME: if the reusable workflow is from a private repository, we need to provide a token to access the repository.
|
||||||
token := ""
|
token := ""
|
||||||
|
@ -91,12 +94,16 @@ func cloneIfRequired(rc *RunContext, remoteReusableWorkflow remoteReusableWorkfl
|
||||||
notExists := errors.Is(err, fs.ErrNotExist)
|
notExists := errors.Is(err, fs.ErrNotExist)
|
||||||
return notExists
|
return notExists
|
||||||
},
|
},
|
||||||
git.NewGitCloneExecutor(git.NewGitCloneExecutorInput{
|
func(ctx context.Context) error {
|
||||||
URL: remoteReusableWorkflow.CloneURL(),
|
// Gitea has already full URL with rc.Config.GitHubInstance
|
||||||
Ref: remoteReusableWorkflow.Ref,
|
//remoteReusableWorkflow.URL = rc.getGithubContext(ctx).ServerURL
|
||||||
Dir: targetDirectory,
|
return git.NewGitCloneExecutor(git.NewGitCloneExecutorInput{
|
||||||
Token: token,
|
URL: remoteReusableWorkflow.CloneURL(),
|
||||||
}),
|
Ref: remoteReusableWorkflow.Ref,
|
||||||
|
Dir: targetDirectory,
|
||||||
|
Token: token,
|
||||||
|
})(ctx)
|
||||||
|
},
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -187,6 +194,6 @@ func newRemoteReusableWorkflow(uses string) *remoteReusableWorkflow {
|
||||||
Repo: matches[2],
|
Repo: matches[2],
|
||||||
Filename: matches[3],
|
Filename: matches[3],
|
||||||
Ref: matches[4],
|
Ref: matches[4],
|
||||||
URL: "github.com",
|
URL: "https://github.com",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -549,8 +549,9 @@ func (rc *RunContext) startContainer() common.Executor {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rc *RunContext) IsHostEnv(ctx context.Context) bool {
|
func (rc *RunContext) IsHostEnv(ctx context.Context) bool {
|
||||||
image := rc.platformImage(ctx)
|
platform := rc.runsOnImage(ctx)
|
||||||
return strings.EqualFold(image, "-self-hosted")
|
image := rc.containerImage(ctx)
|
||||||
|
return image == "" && strings.EqualFold(platform, "-self-hosted")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rc *RunContext) stopContainer() common.Executor {
|
func (rc *RunContext) stopContainer() common.Executor {
|
||||||
|
@ -603,7 +604,7 @@ func (rc *RunContext) Executor() common.Executor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rc *RunContext) platformImage(ctx context.Context) string {
|
func (rc *RunContext) containerImage(ctx context.Context) string {
|
||||||
job := rc.Run.Job()
|
job := rc.Run.Job()
|
||||||
|
|
||||||
c := job.Container()
|
c := job.Container()
|
||||||
|
@ -611,6 +612,12 @@ func (rc *RunContext) platformImage(ctx context.Context) string {
|
||||||
return rc.ExprEval.Interpolate(ctx, c.Image)
|
return rc.ExprEval.Interpolate(ctx, c.Image)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (rc *RunContext) runsOnImage(ctx context.Context) string {
|
||||||
|
job := rc.Run.Job()
|
||||||
|
|
||||||
if job.RunsOn() == nil {
|
if job.RunsOn() == nil {
|
||||||
common.Logger(ctx).Errorf("'runs-on' key not defined in %s", rc.String())
|
common.Logger(ctx).Errorf("'runs-on' key not defined in %s", rc.String())
|
||||||
}
|
}
|
||||||
|
@ -636,6 +643,14 @@ func (rc *RunContext) platformImage(ctx context.Context) string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (rc *RunContext) platformImage(ctx context.Context) string {
|
||||||
|
if containerImage := rc.containerImage(ctx); containerImage != "" {
|
||||||
|
return containerImage
|
||||||
|
}
|
||||||
|
|
||||||
|
return rc.runsOnImage(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
func (rc *RunContext) options(ctx context.Context) string {
|
func (rc *RunContext) options(ctx context.Context) string {
|
||||||
job := rc.Run.Job()
|
job := rc.Run.Job()
|
||||||
c := job.Container()
|
c := job.Container()
|
||||||
|
|
|
@ -4,7 +4,9 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"path"
|
"path"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/nektos/act/pkg/common"
|
"github.com/nektos/act/pkg/common"
|
||||||
"github.com/nektos/act/pkg/container"
|
"github.com/nektos/act/pkg/container"
|
||||||
|
@ -134,7 +136,9 @@ func runStepExecutor(step step, stage stepStage, executor common.Executor) commo
|
||||||
Mode: 0o666,
|
Mode: 0o666,
|
||||||
})(ctx)
|
})(ctx)
|
||||||
|
|
||||||
err = executor(ctx)
|
timeoutctx, cancelTimeOut := evaluateStepTimeout(ctx, rc.ExprEval, stepModel)
|
||||||
|
defer cancelTimeOut()
|
||||||
|
err = executor(timeoutctx)
|
||||||
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
logger.WithField("stepResult", stepResult.Outcome).Infof(" \u2705 Success - %s %s", stage, stepString)
|
logger.WithField("stepResult", stepResult.Outcome).Infof(" \u2705 Success - %s %s", stage, stepString)
|
||||||
|
@ -182,6 +186,16 @@ func runStepExecutor(step step, stage stepStage, executor common.Executor) commo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func evaluateStepTimeout(ctx context.Context, exprEval ExpressionEvaluator, stepModel *model.Step) (context.Context, context.CancelFunc) {
|
||||||
|
timeout := exprEval.Interpolate(ctx, stepModel.TimeoutMinutes)
|
||||||
|
if timeout != "" {
|
||||||
|
if timeOutMinutes, err := strconv.ParseInt(timeout, 10, 64); err == nil {
|
||||||
|
return context.WithTimeout(ctx, time.Duration(timeOutMinutes)*time.Minute)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ctx, func() {}
|
||||||
|
}
|
||||||
|
|
||||||
func setupEnv(ctx context.Context, step step) error {
|
func setupEnv(ctx context.Context, step step) error {
|
||||||
rc := step.getRunContext()
|
rc := step.getRunContext()
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,8 @@ func (sar *stepActionRemote) prepareActionExecutor() common.Executor {
|
||||||
}
|
}
|
||||||
|
|
||||||
github := sar.getGithubContext(ctx)
|
github := sar.getGithubContext(ctx)
|
||||||
|
sar.remoteAction.URL = github.ServerURL
|
||||||
|
|
||||||
if sar.remoteAction.IsCheckout() && isLocalCheckout(github, sar.Step) && !sar.RunContext.Config.NoSkipCheckout {
|
if sar.remoteAction.IsCheckout() && isLocalCheckout(github, sar.Step) && !sar.RunContext.Config.NoSkipCheckout {
|
||||||
common.Logger(ctx).Debugf("Skipping local actions/checkout because workdir was already copied")
|
common.Logger(ctx).Debugf("Skipping local actions/checkout because workdir was already copied")
|
||||||
return nil
|
return nil
|
||||||
|
@ -56,7 +58,7 @@ func (sar *stepActionRemote) prepareActionExecutor() common.Executor {
|
||||||
|
|
||||||
for _, action := range sar.RunContext.Config.ReplaceGheActionWithGithubCom {
|
for _, action := range sar.RunContext.Config.ReplaceGheActionWithGithubCom {
|
||||||
if strings.EqualFold(fmt.Sprintf("%s/%s", sar.remoteAction.Org, sar.remoteAction.Repo), action) {
|
if strings.EqualFold(fmt.Sprintf("%s/%s", sar.remoteAction.Org, sar.remoteAction.Repo), action) {
|
||||||
sar.remoteAction.URL = "github.com"
|
sar.remoteAction.URL = "https://github.com"
|
||||||
github.Token = sar.RunContext.Config.ReplaceGheActionTokenWithGithubCom
|
github.Token = sar.RunContext.Config.ReplaceGheActionTokenWithGithubCom
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue