Skip to content
Merged
4 changes: 2 additions & 2 deletions models/actions/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,14 @@ func (run *ActionRun) HTMLURL() string {
if run.Repo == nil {
return ""
}
return fmt.Sprintf("%s/actions/runs/%d", run.Repo.HTMLURL(), run.Index)
return fmt.Sprintf("%s/actions/runs/%d", run.Repo.HTMLURL(), run.ID)
}

func (run *ActionRun) Link() string {
if run.Repo == nil {
return ""
}
return fmt.Sprintf("%s/actions/runs/%d", run.Repo.Link(), run.Index)
return fmt.Sprintf("%s/actions/runs/%d", run.Repo.Link(), run.ID)
}

func (run *ActionRun) WorkflowLink() string {
Expand Down
2 changes: 1 addition & 1 deletion models/git/commit_status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ func TestCommitStatusesHideActionsURL(t *testing.T) {
statuses := []*git_model.CommitStatus{
{
RepoID: repo.ID,
TargetURL: fmt.Sprintf("%s/jobs/%d", run.Link(), run.Index),
TargetURL: fmt.Sprintf("%s/jobs/%d", run.Link(), run.ID),
},
{
RepoID: repo.ID,
Expand Down
8 changes: 1 addition & 7 deletions routers/api/v1/repo/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -1041,15 +1041,9 @@ func ActionsDispatchWorkflow(ctx *context.APIContext) {
return
}

workflowRun, err := actions_model.GetRunByRepoAndID(ctx, ctx.Repo.Repository.ID, runID)
if err != nil {
ctx.APIErrorInternal(err)
return
}

ctx.JSON(http.StatusOK, &api.RunDetails{
WorkflowRunID: runID,
HTMLURL: fmt.Sprintf("%s/actions/runs/%d", ctx.Repo.Repository.HTMLURL(ctx), workflowRun.Index),
HTMLURL: fmt.Sprintf("%s/actions/runs/%d", ctx.Repo.Repository.HTMLURL(ctx), runID),
RunURL: fmt.Sprintf("%s/actions/runs/%d", ctx.Repo.Repository.APIURL(), runID),
})
}
Expand Down
16 changes: 8 additions & 8 deletions routers/common/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ import (
"code.gitea.io/gitea/services/context"
)

func DownloadActionsRunJobLogsWithIndex(ctx *context.Base, ctxRepo *repo_model.Repository, runID, jobIndex int64) error {
runJobs, err := actions_model.GetRunJobsByRunID(ctx, runID)
func DownloadActionsRunJobLogsWithID(ctx *context.Base, ctxRepo *repo_model.Repository, runID, jobID int64) error {
job, err := actions_model.GetRunJobByID(ctx, jobID)
if err != nil {
return fmt.Errorf("GetRunJobsByRunID: %w", err)
return err
}
if err = runJobs.LoadRepos(ctx); err != nil {
return fmt.Errorf("LoadRepos: %w", err)
if job.RunID != runID {
Comment thread
wxiaoguang marked this conversation as resolved.
Outdated
return util.NewNotExistErrorf("job not found")
}
if jobIndex < 0 || jobIndex >= int64(len(runJobs)) {
return util.NewNotExistErrorf("job index is out of range: %d", jobIndex)
if err := job.LoadRepo(ctx); err != nil {
return fmt.Errorf("LoadRepo: %w", err)
}
return DownloadActionsRunJobLogs(ctx, ctxRepo, runJobs[jobIndex])
return DownloadActionsRunJobLogs(ctx, ctxRepo, job)
}

func DownloadActionsRunJobLogs(ctx *context.Base, ctxRepo *repo_model.Repository, curJob *actions_model.ActionRunJob) error {
Expand Down
4 changes: 2 additions & 2 deletions routers/web/devtest/mock_actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ func generateMockStepsLog(logCur actions.LogCursor, opts generateMockStepsLogOpt
}

func MockActionsView(ctx *context.Context) {
ctx.Data["RunIndex"] = ctx.PathParam("run")
ctx.Data["JobIndex"] = ctx.PathParam("job")
ctx.Data["RunID"] = ctx.PathParam("run")
ctx.Data["JobID"] = ctx.PathParam("job")
ctx.HTML(http.StatusOK, "devtest/repo-action-view")
}

Expand Down
Loading