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:
parent
b65d458c3a
commit
2eb558be4a
3 changed files with 84 additions and 3 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue