Skip to content

Commit

Permalink
Revert "Support for multiple default URLs for getting actions (nektos#58
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfogre committed Jun 30, 2023
1 parent 545802b commit eb19987
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 38 deletions.
3 changes: 1 addition & 2 deletions pkg/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ type Config struct {
ContainerNamePrefix string // the prefix of container name
ContainerMaxLifetime time.Duration // the max lifetime of job containers
ContainerNetworkMode docker_container.NetworkMode // the network mode of job containers (the value of --network)
DefaultActionInstance string // Deprecated: use DefaultActionsURLs instead.
DefaultActionsURLs []string // urls from gitea's `DEFAULT_ACTIONS_URL` config
DefaultActionInstance string // the default actions web site
PlatformPicker func(labels []string) string // platform picker, it will take precedence over Platforms if isn't nil
JobLoggerLevel *log.Level // the level of job logger
ValidVolumes []string // only volumes (and bind mounts) in this slice can be mounted on the job container or service containers
Expand Down
37 changes: 1 addition & 36 deletions pkg/runner/step_action_remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@ import (
"errors"
"fmt"
"io"
"net/http"
"os"
"path"
"path/filepath"
"regexp"
"strings"
"time"

gogit "github.com/go-git/go-git/v5"

Expand All @@ -20,8 +18,6 @@ import (
"github.com/nektos/act/pkg/model"
)

var detectActionClient = http.Client{Timeout: 5 * time.Second}

type stepActionRemote struct {
Step *model.Step
RunContext *RunContext
Expand Down Expand Up @@ -61,14 +57,9 @@ func (sar *stepActionRemote) prepareActionExecutor() common.Executor {
}
}

cloneURL, err := sar.remoteAction.GetAvailableCloneURL(sar.RunContext.Config.DefaultActionsURLs)
if err != nil {
return fmt.Errorf("failed to get available clone url of [%s] action, error: %w", sar.Step.Uses, err)
}

actionDir := fmt.Sprintf("%s/%s", sar.RunContext.ActionCacheDir(), safeFilename(sar.Step.Uses))
gitClone := stepActionRemoteNewCloneExecutor(git.NewGitCloneExecutorInput{
URL: cloneURL,
URL: sar.remoteAction.CloneURL(sar.RunContext.Config.DefaultActionInstance),
Ref: sar.remoteAction.Ref,
Dir: actionDir,
Token: "", /*
Expand Down Expand Up @@ -237,32 +228,6 @@ func (ra *remoteAction) IsCheckout() bool {
return false
}

func (ra *remoteAction) GetAvailableCloneURL(actionURLs []string) (string, error) {
if ra.URL != "" {
return ra.CloneURL(ra.URL), nil
}
for _, u := range actionURLs {
cloneURL := ra.CloneURL(u)
resp, err := detectActionClient.Get(cloneURL)
if err != nil {
return "", err
}
defer resp.Body.Close()

switch resp.StatusCode {
case http.StatusOK:
return cloneURL, nil
case http.StatusNotFound:
continue

default:
return "", fmt.Errorf("unexpected http status code: %d", resp.StatusCode)
}
}

return "", fmt.Errorf("no available url found")
}

func newRemoteAction(action string) *remoteAction {
// support http(s)://host/owner/repo@v3
for _, schema := range []string{"https://", "http://"} {
Expand Down

0 comments on commit eb19987

Please sign in to comment.