Skip to content

Commit eb19987

Browse files
committed
Revert "Support for multiple default URLs for getting actions (#58)" (#70)
Follow go-gitea/gitea#25581 . Reviewed-on: https://gitea.com/gitea/act/pulls/70
1 parent 545802b commit eb19987

File tree

2 files changed

+2
-38
lines changed

2 files changed

+2
-38
lines changed

pkg/runner/runner.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ type Config struct {
6565
ContainerNamePrefix string // the prefix of container name
6666
ContainerMaxLifetime time.Duration // the max lifetime of job containers
6767
ContainerNetworkMode docker_container.NetworkMode // the network mode of job containers (the value of --network)
68-
DefaultActionInstance string // Deprecated: use DefaultActionsURLs instead.
69-
DefaultActionsURLs []string // urls from gitea's `DEFAULT_ACTIONS_URL` config
68+
DefaultActionInstance string // the default actions web site
7069
PlatformPicker func(labels []string) string // platform picker, it will take precedence over Platforms if isn't nil
7170
JobLoggerLevel *log.Level // the level of job logger
7271
ValidVolumes []string // only volumes (and bind mounts) in this slice can be mounted on the job container or service containers

pkg/runner/step_action_remote.go

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@ import (
55
"errors"
66
"fmt"
77
"io"
8-
"net/http"
98
"os"
109
"path"
1110
"path/filepath"
1211
"regexp"
1312
"strings"
14-
"time"
1513

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

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

23-
var detectActionClient = http.Client{Timeout: 5 * time.Second}
24-
2521
type stepActionRemote struct {
2622
Step *model.Step
2723
RunContext *RunContext
@@ -61,14 +57,9 @@ func (sar *stepActionRemote) prepareActionExecutor() common.Executor {
6157
}
6258
}
6359

64-
cloneURL, err := sar.remoteAction.GetAvailableCloneURL(sar.RunContext.Config.DefaultActionsURLs)
65-
if err != nil {
66-
return fmt.Errorf("failed to get available clone url of [%s] action, error: %w", sar.Step.Uses, err)
67-
}
68-
6960
actionDir := fmt.Sprintf("%s/%s", sar.RunContext.ActionCacheDir(), safeFilename(sar.Step.Uses))
7061
gitClone := stepActionRemoteNewCloneExecutor(git.NewGitCloneExecutorInput{
71-
URL: cloneURL,
62+
URL: sar.remoteAction.CloneURL(sar.RunContext.Config.DefaultActionInstance),
7263
Ref: sar.remoteAction.Ref,
7364
Dir: actionDir,
7465
Token: "", /*
@@ -237,32 +228,6 @@ func (ra *remoteAction) IsCheckout() bool {
237228
return false
238229
}
239230

240-
func (ra *remoteAction) GetAvailableCloneURL(actionURLs []string) (string, error) {
241-
if ra.URL != "" {
242-
return ra.CloneURL(ra.URL), nil
243-
}
244-
for _, u := range actionURLs {
245-
cloneURL := ra.CloneURL(u)
246-
resp, err := detectActionClient.Get(cloneURL)
247-
if err != nil {
248-
return "", err
249-
}
250-
defer resp.Body.Close()
251-
252-
switch resp.StatusCode {
253-
case http.StatusOK:
254-
return cloneURL, nil
255-
case http.StatusNotFound:
256-
continue
257-
258-
default:
259-
return "", fmt.Errorf("unexpected http status code: %d", resp.StatusCode)
260-
}
261-
}
262-
263-
return "", fmt.Errorf("no available url found")
264-
}
265-
266231
func newRemoteAction(action string) *remoteAction {
267232
// support http(s)://host/owner/repo@v3
268233
for _, schema := range []string{"https://", "http://"} {

0 commit comments

Comments
 (0)