1
0
Fork 0
forked from forgejo/forgejo

[CI] DEFAULT_ACTIONS_URL support for self & github (squash)

Refs: https://codeberg.org/forgejo/forgejo/issues/1062
(cherry picked from commit 74cc25376e)
This commit is contained in:
Loïc Dachary 2023-07-19 14:06:28 +02:00
parent b65d458c3a
commit 2eb558be4a
No known key found for this signature in database
GPG key ID: 992D23B392F9E4F2
3 changed files with 84 additions and 3 deletions

View file

@ -5,6 +5,7 @@ package setting
import (
"fmt"
"strings"
)
// Actions settings
@ -13,13 +14,32 @@ var (
LogStorage *Storage // how the created logs should be stored
ArtifactStorage *Storage // how the created artifacts should be stored
Enabled bool
DefaultActionsURL string `ini:"DEFAULT_ACTIONS_URL"`
DefaultActionsURL defaultActionsURL `ini:"DEFAULT_ACTIONS_URL"`
}{
Enabled: false,
DefaultActionsURL: "https://code.forgejo.org",
DefaultActionsURL: defaultActionsURLForgejo,
}
)
type defaultActionsURL string
func (url defaultActionsURL) URL() string {
switch url {
case defaultActionsURLGitHub:
return "https://github.com"
case defaultActionsURLSelf:
return strings.TrimSuffix(AppURL, "/")
default:
return string(url)
}
}
const (
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 {
sec := rootCfg.Section("actions")
err := sec.MapTo(&Actions)