support bot site
This commit is contained in:
parent
7815eec33b
commit
113c3e98fb
3 changed files with 24 additions and 15 deletions
|
@ -177,15 +177,15 @@ func (rc *RunContext) startJobContainer() common.Executor {
|
||||||
rc.JobContainer.UpdateFromEnv("/etc/environment", &rc.Env),
|
rc.JobContainer.UpdateFromEnv("/etc/environment", &rc.Env),
|
||||||
rc.JobContainer.Copy(ActPath+"/", &container.FileEntry{
|
rc.JobContainer.Copy(ActPath+"/", &container.FileEntry{
|
||||||
Name: "workflow/event.json",
|
Name: "workflow/event.json",
|
||||||
Mode: 0644,
|
Mode: 0o644,
|
||||||
Body: rc.EventJSON,
|
Body: rc.EventJSON,
|
||||||
}, &container.FileEntry{
|
}, &container.FileEntry{
|
||||||
Name: "workflow/envs.txt",
|
Name: "workflow/envs.txt",
|
||||||
Mode: 0666,
|
Mode: 0o666,
|
||||||
Body: "",
|
Body: "",
|
||||||
}, &container.FileEntry{
|
}, &container.FileEntry{
|
||||||
Name: "workflow/paths.txt",
|
Name: "workflow/paths.txt",
|
||||||
Mode: 0666,
|
Mode: 0o666,
|
||||||
Body: "",
|
Body: "",
|
||||||
}),
|
}),
|
||||||
)(ctx)
|
)(ctx)
|
||||||
|
@ -588,9 +588,16 @@ func (rc *RunContext) withGithubEnv(ctx context.Context, github *model.GithubCon
|
||||||
env["RUNNER_PERFLOG"] = github.RunnerPerflog
|
env["RUNNER_PERFLOG"] = github.RunnerPerflog
|
||||||
env["RUNNER_TRACKING_ID"] = github.RunnerTrackingID
|
env["RUNNER_TRACKING_ID"] = github.RunnerTrackingID
|
||||||
if rc.Config.GitHubInstance != "github.com" {
|
if rc.Config.GitHubInstance != "github.com" {
|
||||||
env["GITHUB_SERVER_URL"] = fmt.Sprintf("https://%s", rc.Config.GitHubInstance)
|
hasProtocol := strings.HasPrefix(rc.Config.GitHubInstance, "http://") || strings.HasPrefix(rc.Config.GitHubInstance, "https://")
|
||||||
env["GITHUB_API_URL"] = fmt.Sprintf("https://%s/api/v3", rc.Config.GitHubInstance)
|
if hasProtocol {
|
||||||
env["GITHUB_GRAPHQL_URL"] = fmt.Sprintf("https://%s/api/graphql", rc.Config.GitHubInstance)
|
env["GITHUB_SERVER_URL"] = rc.Config.GitHubInstance
|
||||||
|
env["GITHUB_API_URL"] = fmt.Sprintf("%s/api/v3", rc.Config.GitHubInstance) // FIXME: gitea is v1 not v3
|
||||||
|
env["GITHUB_GRAPHQL_URL"] = fmt.Sprintf("%s/api/graphql", rc.Config.GitHubInstance)
|
||||||
|
} else {
|
||||||
|
env["GITHUB_SERVER_URL"] = fmt.Sprintf("https://%s", rc.Config.GitHubInstance)
|
||||||
|
env["GITHUB_API_URL"] = fmt.Sprintf("https://%s/api/v3", rc.Config.GitHubInstance)
|
||||||
|
env["GITHUB_GRAPHQL_URL"] = fmt.Sprintf("https://%s/api/graphql", rc.Config.GitHubInstance)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if rc.Config.ArtifactServerPath != "" {
|
if rc.Config.ArtifactServerPath != "" {
|
||||||
|
|
|
@ -56,9 +56,10 @@ type Config struct {
|
||||||
ReplaceGheActionWithGithubCom []string // Use actions from GitHub Enterprise instance to GitHub
|
ReplaceGheActionWithGithubCom []string // Use actions from GitHub Enterprise instance to GitHub
|
||||||
ReplaceGheActionTokenWithGithubCom string // Token of private action repo on GitHub.
|
ReplaceGheActionTokenWithGithubCom string // Token of private action repo on GitHub.
|
||||||
|
|
||||||
PresetGitHubContext *model.GithubContext // the preset github context, overrides some fields like DefaultBranch, Env, Secrets etc.
|
PresetGitHubContext *model.GithubContext // the preset github context, overrides some fields like DefaultBranch, Env, Secrets etc.
|
||||||
EventJSON string // the content of JSON file to use for event.json in containers, overrides EventPath
|
EventJSON string // the content of JSON file to use for event.json in containers, overrides EventPath
|
||||||
ContainerNamePrefix string // the prefix of container name
|
ContainerNamePrefix string // the prefix of container name
|
||||||
|
DefaultActionInstance string // the default actions web site
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resolves the equivalent host path inside the container
|
// Resolves the equivalent host path inside the container
|
||||||
|
|
|
@ -30,9 +30,7 @@ type stepActionRemote struct {
|
||||||
remoteAction *remoteAction
|
remoteAction *remoteAction
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var stepActionRemoteNewCloneExecutor = git.NewGitCloneExecutor
|
||||||
stepActionRemoteNewCloneExecutor = git.NewGitCloneExecutor
|
|
||||||
)
|
|
||||||
|
|
||||||
func (sar *stepActionRemote) prepareActionExecutor() common.Executor {
|
func (sar *stepActionRemote) prepareActionExecutor() common.Executor {
|
||||||
return func(ctx context.Context) error {
|
return func(ctx context.Context) error {
|
||||||
|
@ -46,7 +44,7 @@ func (sar *stepActionRemote) prepareActionExecutor() common.Executor {
|
||||||
return fmt.Errorf("Expected format {org}/{repo}[/path]@ref. Actual '%s' Input string was not in a correct format", sar.Step.Uses)
|
return fmt.Errorf("Expected format {org}/{repo}[/path]@ref. Actual '%s' Input string was not in a correct format", sar.Step.Uses)
|
||||||
}
|
}
|
||||||
|
|
||||||
sar.remoteAction.URL = sar.RunContext.Config.GitHubInstance
|
sar.remoteAction.URL = sar.RunContext.Config.DefaultActionInstance
|
||||||
|
|
||||||
github := sar.getGithubContext(ctx)
|
github := sar.getGithubContext(ctx)
|
||||||
if sar.remoteAction.IsCheckout() && isLocalCheckout(github, sar.Step) && !sar.RunContext.Config.NoSkipCheckout {
|
if sar.remoteAction.IsCheckout() && isLocalCheckout(github, sar.Step) && !sar.RunContext.Config.NoSkipCheckout {
|
||||||
|
@ -54,7 +52,6 @@ func (sar *stepActionRemote) prepareActionExecutor() common.Executor {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
sar.remoteAction.URL = sar.RunContext.Config.GitHubInstance
|
|
||||||
for _, action := range sar.RunContext.Config.ReplaceGheActionWithGithubCom {
|
for _, action := range sar.RunContext.Config.ReplaceGheActionWithGithubCom {
|
||||||
if strings.EqualFold(fmt.Sprintf("%s/%s", sar.remoteAction.Org, sar.remoteAction.Repo), action) {
|
if strings.EqualFold(fmt.Sprintf("%s/%s", sar.remoteAction.Org, sar.remoteAction.Repo), action) {
|
||||||
sar.remoteAction.URL = "github.com"
|
sar.remoteAction.URL = "github.com"
|
||||||
|
@ -213,7 +210,11 @@ type remoteAction struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ra *remoteAction) CloneURL() string {
|
func (ra *remoteAction) CloneURL() string {
|
||||||
return fmt.Sprintf("https://%s/%s/%s", ra.URL, ra.Org, ra.Repo)
|
u := ra.URL
|
||||||
|
if !strings.HasPrefix(u, "http://") && !strings.HasPrefix(u, "https://") {
|
||||||
|
u = "https://" + u
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("%s/%s/%s", u, ra.Org, ra.Repo)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ra *remoteAction) IsCheckout() bool {
|
func (ra *remoteAction) IsCheckout() bool {
|
||||||
|
|
Loading…
Reference in a new issue