diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini index 301e88b14..18b54aa15 100644 --- a/custom/conf/app.example.ini +++ b/custom/conf/app.example.ini @@ -2579,10 +2579,9 @@ LEVEL = Info ; [actions] ;; Enable/Disable actions capabilities ;ENABLED = true -;; -;; Default platform to get action plugins, `github` for `https://github.com`, `self` for the current Gitea instance. -;DEFAULT_ACTIONS_URL = github -;; Default artifact retention time in days. Artifacts could have their own retention periods by setting the `retention-days` option in `actions/upload-artifact` step. +;; Default address to get action plugins, e.g. the default value means downloading from "https://code.forgejo.org/actions/checkout" for "uses: actions/checkout@v3" +;DEFAULT_ACTIONS_URL = https://code.forgejo.org +;; Default artifact retention time in days, default is 90 days ;ARTIFACT_RETENTION_DAYS = 90 ;; Timeout to stop the task which have running status, but haven't been updated for a long time ;ZOMBIE_TASK_TIMEOUT = 10m diff --git a/modules/setting/actions.go b/modules/setting/actions.go index 9fd484c3b..e9b735dae 100644 --- a/modules/setting/actions.go +++ b/modules/setting/actions.go @@ -7,8 +7,6 @@ import ( "fmt" "strings" "time" - - "code.gitea.io/gitea/modules/log" ) // Actions settings @@ -25,7 +23,7 @@ var ( SkipWorkflowStrings []string `ìni:"SKIP_WORKFLOW_STRINGS"` }{ Enabled: true, - DefaultActionsURL: defaultActionsURLGitHub, + DefaultActionsURL: defaultActionsURLForgejo, SkipWorkflowStrings: []string{"[skip ci]", "[ci skip]", "[no ci]", "[skip actions]", "[actions skip]"}, } ) @@ -39,18 +37,14 @@ 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 string(url) } } const ( - defaultActionsURLGitHub = "github" // https://github.com - defaultActionsURLSelf = "self" // the root URL of the self-hosted Gitea instance - // DefaultActionsURL only supports GitHub and the self-hosted Gitea. - // It's intentionally not supported more, so please be cautious before adding more like "gitea" or "gitlab". - // If you get some trouble with `uses: username/action_name@version` in your workflow, - // please consider to use `uses: https://the_url_you_want_to_use/username/action_name@version` instead. + defaultActionsURLForgejo = "https://code.forgejo.org" + defaultActionsURLGitHub = "github" // https://github.com + defaultActionsURLSelf = "self" // the root URL of the self-hosted instance ) func loadActionsFrom(rootCfg ConfigProvider) error { @@ -60,19 +54,6 @@ func loadActionsFrom(rootCfg ConfigProvider) error { return fmt.Errorf("failed to map Actions settings: %v", err) } - 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 - } else { - return fmt.Errorf("unsupported [actions] DEFAULT_ACTIONS_URL: %q", urls) - } - } - // don't support to read configuration from [actions] Actions.LogStorage, err = getStorage(rootCfg, "actions_log", "", nil) if err != nil { diff --git a/modules/setting/actions_test.go b/modules/setting/actions_test.go index 3645a3f5d..01f5bf74a 100644 --- a/modules/setting/actions_test.go +++ b/modules/setting/actions_test.go @@ -110,7 +110,6 @@ func Test_getDefaultActionsURLForActions(t *testing.T) { tests := []struct { name string iniStr string - wantErr assert.ErrorAssertionFunc wantURL string }{ { @@ -118,8 +117,7 @@ func Test_getDefaultActionsURLForActions(t *testing.T) { iniStr: ` [actions] `, - wantErr: assert.NoError, - wantURL: "https://github.com", + wantURL: "https://code.forgejo.org", }, { name: "github", @@ -127,7 +125,6 @@ func Test_getDefaultActionsURLForActions(t *testing.T) { [actions] DEFAULT_ACTIONS_URL = github `, - wantErr: assert.NoError, wantURL: "https://github.com", }, { @@ -136,35 +133,15 @@ DEFAULT_ACTIONS_URL = github [actions] DEFAULT_ACTIONS_URL = self `, - wantErr: assert.NoError, wantURL: "http://test_get_default_actions_url_for_actions:3000", }, - { - name: "custom url", - iniStr: ` -[actions] -DEFAULT_ACTIONS_URL = https://gitea.com -`, - wantErr: assert.NoError, - wantURL: "https://github.com", - }, { name: "custom urls", iniStr: ` [actions] -DEFAULT_ACTIONS_URL = https://gitea.com,https://github.com +DEFAULT_ACTIONS_URL = https://example.com `, - wantErr: assert.NoError, - wantURL: "https://github.com", - }, - { - name: "invalid", - iniStr: ` -[actions] -DEFAULT_ACTIONS_URL = gitea -`, - wantErr: assert.Error, - wantURL: "https://github.com", + wantURL: "https://example.com", }, } @@ -172,7 +149,7 @@ DEFAULT_ACTIONS_URL = gitea t.Run(tt.name, func(t *testing.T) { cfg, err := NewConfigProviderFromData(tt.iniStr) require.NoError(t, err) - if !tt.wantErr(t, loadActionsFrom(cfg)) { + if !assert.NoError(t, loadActionsFrom(cfg)) { return } assert.EqualValues(t, tt.wantURL, Actions.DefaultActionsURL.URL())