refactor: rename to actions
This commit is contained in:
@@ -331,7 +331,7 @@ func generateTaskContext(t *actions_model.ActionTask) *structpb.Struct {
|
||||
"workspace": "", // string, The default working directory on the runner for steps, and the default location of your repository when using the checkout action.
|
||||
|
||||
// additional contexts
|
||||
"gitea_default_bots_url": setting.Bots.DefaultBotsURL,
|
||||
"gitea_default_actions_url": setting.Actions.DefaultActionsURL,
|
||||
})
|
||||
|
||||
return taskContext
|
||||
|
||||
@@ -185,9 +185,9 @@ func repoAssignment() func(ctx *context.APIContext) {
|
||||
repo.Owner = owner
|
||||
ctx.Repo.Repository = repo
|
||||
|
||||
if ctx.Doer != nil && ctx.Doer.ID == user_model.BotUserID {
|
||||
botTaskID := ctx.Data["BotTaskID"].(int64)
|
||||
task, err := actions_model.GetTaskByID(ctx, botTaskID)
|
||||
if ctx.Doer != nil && ctx.Doer.ID == user_model.ActionsUserID {
|
||||
taskID := ctx.Data["ActionsTaskID"].(int64)
|
||||
task, err := actions_model.GetTaskByID(ctx, taskID)
|
||||
if err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "actions_model.GetTaskByID", err)
|
||||
return
|
||||
@@ -239,7 +239,7 @@ func reqPackageAccess(accessMode perm.AccessMode) func(ctx *context.APIContext)
|
||||
// Contexter middleware already checks token for user sign in process.
|
||||
func reqToken() func(ctx *context.APIContext) {
|
||||
return func(ctx *context.APIContext) {
|
||||
if true == ctx.Data["IsApiToken"] || true == ctx.Data["IsBotToken"] {
|
||||
if true == ctx.Data["IsApiToken"] || true == ctx.Data["IsActionsToken"] {
|
||||
return
|
||||
}
|
||||
if ctx.Context.IsBasicAuth {
|
||||
|
||||
@@ -202,8 +202,8 @@ func NormalRoutes(ctx context.Context) *web.Route {
|
||||
r.Mount("/v2", packages_router.ContainerRoutes(ctx))
|
||||
}
|
||||
|
||||
if setting.Bots.Enabled {
|
||||
prefix := "/api/bots"
|
||||
if setting.Actions.Enabled {
|
||||
prefix := "/api/actions"
|
||||
r.Mount(prefix, actions_router.Routes(ctx, prefix))
|
||||
}
|
||||
|
||||
|
||||
@@ -464,8 +464,8 @@ func (ctx *preReceiveContext) loadPusherAndPermission() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
if ctx.opts.UserID == user_model.BotUserID {
|
||||
ctx.user = user_model.NewBotUser()
|
||||
if ctx.opts.UserID == user_model.ActionsUserID {
|
||||
ctx.user = user_model.NewActionsUser()
|
||||
ctx.userPerm.AccessMode = perm_model.AccessModeAdmin
|
||||
if err := ctx.Repo.Repository.LoadUnits(ctx); err != nil {
|
||||
log.Error("Unable to get User id %d Error: %v", ctx.opts.UserID, err)
|
||||
|
||||
@@ -18,33 +18,33 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
tplListBots base.TplName = "repo/bots/list"
|
||||
tplViewBuild base.TplName = "repo/bots/view"
|
||||
tplListActions base.TplName = "repo/actions/list"
|
||||
tplViewActions base.TplName = "repo/actions/view"
|
||||
)
|
||||
|
||||
// MustEnableBots check if bots are enabled in settings
|
||||
func MustEnableBots(ctx *context.Context) {
|
||||
if !setting.Bots.Enabled {
|
||||
ctx.NotFound("MustEnableBots", nil)
|
||||
// MustEnableActions check if actions are enabled in settings
|
||||
func MustEnableActions(ctx *context.Context) {
|
||||
if !setting.Actions.Enabled {
|
||||
ctx.NotFound("MustEnableActions", nil)
|
||||
return
|
||||
}
|
||||
|
||||
if unit.TypeBots.UnitGlobalDisabled() {
|
||||
ctx.NotFound("MustEnableBots", nil)
|
||||
if unit.TypeActions.UnitGlobalDisabled() {
|
||||
ctx.NotFound("MustEnableActions", nil)
|
||||
return
|
||||
}
|
||||
|
||||
if ctx.Repo.Repository != nil {
|
||||
if !ctx.Repo.CanRead(unit.TypeBots) {
|
||||
ctx.NotFound("MustEnableBots", nil)
|
||||
if !ctx.Repo.CanRead(unit.TypeActions) {
|
||||
ctx.NotFound("MustEnableActions", nil)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func List(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("repo.bots")
|
||||
ctx.Data["PageIsBots"] = true
|
||||
ctx.Data["Title"] = ctx.Tr("repo.actions")
|
||||
ctx.Data["PageIsActions"] = true
|
||||
|
||||
defaultBranch, err := ctx.Repo.GitRepo.GetDefaultBranch()
|
||||
if err != nil {
|
||||
@@ -129,5 +129,5 @@ func List(ctx *context.Context) {
|
||||
pager.SetDefaultParams(ctx)
|
||||
ctx.Data["Page"] = pager
|
||||
|
||||
ctx.HTML(http.StatusOK, tplListBots)
|
||||
ctx.HTML(http.StatusOK, tplListActions)
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ import (
|
||||
)
|
||||
|
||||
func View(ctx *context_module.Context) {
|
||||
ctx.Data["PageIsBots"] = true
|
||||
ctx.Data["PageIsActions"] = true
|
||||
runIndex := ctx.ParamsInt64("run")
|
||||
jobIndex := ctx.ParamsInt64("job")
|
||||
ctx.Data["RunIndex"] = runIndex
|
||||
@@ -37,7 +37,7 @@ func View(ctx *context_module.Context) {
|
||||
run := job.Run
|
||||
ctx.Data["Build"] = run
|
||||
|
||||
ctx.HTML(http.StatusOK, tplViewBuild)
|
||||
ctx.HTML(http.StatusOK, tplViewActions)
|
||||
}
|
||||
|
||||
type ViewRequest struct {
|
||||
|
||||
@@ -164,7 +164,7 @@ func httpBase(ctx *context.Context) (h *serviceHandler) {
|
||||
return
|
||||
}
|
||||
|
||||
if ctx.IsBasicAuth && ctx.Data["IsApiToken"] != true && ctx.Data["IsBotToken"] != true {
|
||||
if ctx.IsBasicAuth && ctx.Data["IsApiToken"] != true && ctx.Data["IsActionsToken"] != true {
|
||||
_, err = auth.GetTwoFactorByUID(ctx.Doer.ID)
|
||||
if err == nil {
|
||||
// TODO: This response should be changed to "invalid credentials" for security reasons once the expectation behind it (creating an app token to authenticate) is properly documented
|
||||
@@ -187,8 +187,8 @@ func httpBase(ctx *context.Context) (h *serviceHandler) {
|
||||
accessMode = perm.AccessModeRead
|
||||
}
|
||||
|
||||
if ctx.Data["IsBotToken"] == true {
|
||||
taskID := ctx.Data["BotTaskID"].(int64)
|
||||
if ctx.Data["IsActionsToken"] == true {
|
||||
taskID := ctx.Data["ActionsTaskID"].(int64)
|
||||
task, err := actions_model.GetTaskByID(ctx, taskID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetTaskByID", err)
|
||||
|
||||
@@ -489,13 +489,13 @@ func SettingsPost(ctx *context.Context) {
|
||||
deleteUnitTypes = append(deleteUnitTypes, unit_model.TypePackages)
|
||||
}
|
||||
|
||||
if form.EnableBots && !unit_model.TypeBots.UnitGlobalDisabled() {
|
||||
if form.EnableActions && !unit_model.TypeActions.UnitGlobalDisabled() {
|
||||
units = append(units, repo_model.RepoUnit{
|
||||
RepoID: repo.ID,
|
||||
Type: unit_model.TypeBots,
|
||||
Type: unit_model.TypeActions,
|
||||
})
|
||||
} else if !unit_model.TypeBots.UnitGlobalDisabled() {
|
||||
deleteUnitTypes = append(deleteUnitTypes, unit_model.TypeBots)
|
||||
} else if !unit_model.TypeActions.UnitGlobalDisabled() {
|
||||
deleteUnitTypes = append(deleteUnitTypes, unit_model.TypeActions)
|
||||
}
|
||||
|
||||
if form.EnablePulls && !unit_model.TypePullRequests.UnitGlobalDisabled() {
|
||||
|
||||
@@ -629,7 +629,7 @@ func RegisterRoutes(m *web.Route) {
|
||||
m.Get("/reset_registration_token", admin.ResetRunnerRegistrationToken)
|
||||
m.Combo("/{runnerid}").Get(admin.EditRunner).Post(bindIgnErr(forms.EditRunnerForm{}), admin.EditRunnerPost)
|
||||
m.Post("/{runnerid}/delete", admin.DeleteRunnerPost)
|
||||
}, actions.MustEnableBots)
|
||||
}, actions.MustEnableActions)
|
||||
}, func(ctx *context.Context) {
|
||||
ctx.Data["EnableOAuth2"] = setting.OAuth2.Enable
|
||||
ctx.Data["EnablePackages"] = setting.Packages.Enabled
|
||||
@@ -672,7 +672,7 @@ func RegisterRoutes(m *web.Route) {
|
||||
reqRepoIssuesOrPullsReader := context.RequireRepoReaderOr(unit.TypeIssues, unit.TypePullRequests)
|
||||
reqRepoProjectsReader := context.RequireRepoReader(unit.TypeProjects)
|
||||
reqRepoProjectsWriter := context.RequireRepoWriter(unit.TypeProjects)
|
||||
reqRepoBotsReader := context.RequireRepoReader(unit.TypeBots)
|
||||
reqRepoActionsReader := context.RequireRepoReader(unit.TypeActions)
|
||||
|
||||
reqPackageAccess := func(accessMode perm.AccessMode) func(ctx *context.Context) {
|
||||
return func(ctx *context.Context) {
|
||||
@@ -792,7 +792,7 @@ func RegisterRoutes(m *web.Route) {
|
||||
Post(bindIgnErr(forms.EditRunnerForm{}), org.RunnersEditPost)
|
||||
m.Post("/{runnerid}/delete", org.RunnerDeletePost)
|
||||
m.Get("/reset_registration_token", org.ResetRunnerRegistrationToken)
|
||||
}, actions.MustEnableBots)
|
||||
}, actions.MustEnableActions)
|
||||
|
||||
m.Group("/secrets", func() {
|
||||
m.Get("", org.Secrets)
|
||||
@@ -960,7 +960,7 @@ func RegisterRoutes(m *web.Route) {
|
||||
Post(bindIgnErr(forms.EditRunnerForm{}), repo.RunnersEditPost)
|
||||
m.Post("/{runnerid}/delete", repo.RunnerDeletePost)
|
||||
m.Get("/reset_registration_token", repo.ResetRunnerRegistrationToken)
|
||||
}, actions.MustEnableBots)
|
||||
}, actions.MustEnableActions)
|
||||
}, func(ctx *context.Context) {
|
||||
ctx.Data["PageIsSettings"] = true
|
||||
ctx.Data["LFSStartServer"] = setting.LFS.StartServer
|
||||
@@ -1199,7 +1199,7 @@ func RegisterRoutes(m *web.Route) {
|
||||
}, reqRepoProjectsWriter, context.RepoMustNotBeArchived())
|
||||
}, reqRepoProjectsReader, repo.MustEnableProjects)
|
||||
|
||||
m.Group("/bots", func() {
|
||||
m.Group("/actions", func() {
|
||||
m.Get("", actions.List)
|
||||
|
||||
m.Group("/runs/{run}", func() {
|
||||
@@ -1214,7 +1214,7 @@ func RegisterRoutes(m *web.Route) {
|
||||
})
|
||||
m.Post("/cancel", actions.Cancel)
|
||||
})
|
||||
}, reqRepoBotsReader, actions.MustEnableBots)
|
||||
}, reqRepoActionsReader, actions.MustEnableActions)
|
||||
|
||||
m.Group("/wiki", func() {
|
||||
m.Combo("/").
|
||||
|
||||
Reference in New Issue
Block a user