0
0
mirror of https://github.com/go-gitea/gitea.git synced 2026-01-19 01:12:00 +01:00

Fix #36395: Allow custom DEFAULT_ACTIONS_URL in configuration

This commit is contained in:
Shravani Totre 2026-01-17 23:24:01 +05:30
parent 65422fde4d
commit 065af3a412
2 changed files with 7 additions and 12 deletions

View File

@ -7,8 +7,6 @@ import (
"fmt"
"strings"
"time"
"code.gitea.io/gitea/modules/log"
)
// Actions settings
@ -41,8 +39,7 @@ func (url defaultActionsURL) URL() string {
case defaultActionsURLSelf:
return strings.TrimSuffix(AppURL, "/")
default:
// This should never happen, but just in case, use GitHub as fallback
return "https://github.com"
return strings.Split(string(url), ",")[0]
}
}
@ -79,11 +76,9 @@ func loadActionsFrom(rootCfg ConfigProvider) error {
if urls := string(Actions.DefaultActionsURL); urls != defaultActionsURLGitHub && urls != defaultActionsURLSelf {
url := strings.Split(urls, ",")[0]
if strings.HasPrefix(url, "https://") || strings.HasPrefix(url, "http://") {
log.Error("[actions] DEFAULT_ACTIONS_URL does not support %q as custom URL any longer, fallback to %q",
urls,
defaultActionsURLGitHub,
)
Actions.DefaultActionsURL = defaultActionsURLGitHub
// Users may want to define their own default actions URL, e.g. "https://github.com" or a self-hosted mirror.
// So we should not force the fallback to "github" (defaultActionsURLGitHub) here.
// The user should ensure the URL is valid and accessible.
} else {
return fmt.Errorf("unsupported [actions] DEFAULT_ACTIONS_URL: %q", urls)
}

View File

@ -146,7 +146,7 @@ DEFAULT_ACTIONS_URL = self
DEFAULT_ACTIONS_URL = https://gitea.com
`,
wantErr: assert.NoError,
wantURL: "https://github.com",
wantURL: "https://gitea.com",
},
{
name: "custom urls",
@ -155,7 +155,7 @@ DEFAULT_ACTIONS_URL = https://gitea.com
DEFAULT_ACTIONS_URL = https://gitea.com,https://github.com
`,
wantErr: assert.NoError,
wantURL: "https://github.com",
wantURL: "https://gitea.com",
},
{
name: "invalid",
@ -164,7 +164,7 @@ DEFAULT_ACTIONS_URL = https://gitea.com,https://github.com
DEFAULT_ACTIONS_URL = gitea
`,
wantErr: assert.Error,
wantURL: "https://github.com",
wantURL: "gitea",
},
}