mirror of
https://github.com/go-gitea/gitea.git
synced 2025-07-21 12:24:38 +02:00
use ToActionsStatus
This commit is contained in:
parent
988cafe780
commit
20f5d6ee95
@ -232,7 +232,7 @@ func ToActionTask(ctx context.Context, t *actions_model.ActionTask) (*api.Action
|
||||
}
|
||||
|
||||
func ToActionWorkflowRun(repo *repo_model.Repository, run *actions_model.ActionRun) (*api.ActionWorkflowRun, error) {
|
||||
status, conclusion := toActionStatus(run.Status)
|
||||
status, conclusion := ToActionsStatus(run.Status)
|
||||
return &api.ActionWorkflowRun{
|
||||
ID: run.ID,
|
||||
URL: fmt.Sprintf("%s/actions/runs/%d", repo.APIURL(), run.ID),
|
||||
@ -250,7 +250,7 @@ func ToActionWorkflowRun(repo *repo_model.Repository, run *actions_model.ActionR
|
||||
}, nil
|
||||
}
|
||||
|
||||
func toActionStatus(status actions_model.Status) (string, string) {
|
||||
func ToActionsStatus(status actions_model.Status) (string, string) {
|
||||
var action string
|
||||
var conclusion string
|
||||
switch status {
|
||||
@ -294,7 +294,7 @@ func ToActionWorkflowJob(ctx context.Context, repo *repo_model.Repository, job *
|
||||
}
|
||||
}
|
||||
|
||||
status, conclusion := toActionStatus(job.Status)
|
||||
status, conclusion := ToActionsStatus(job.Status)
|
||||
var runnerID int64
|
||||
var runnerName string
|
||||
var steps []*api.ActionWorkflowStep
|
||||
@ -307,7 +307,7 @@ func ToActionWorkflowJob(ctx context.Context, repo *repo_model.Repository, job *
|
||||
runnerName = runner.Name
|
||||
}
|
||||
for i, step := range task.Steps {
|
||||
stepStatus, stepConclusion := toActionStatus(job.Status)
|
||||
stepStatus, stepConclusion := ToActionsStatus(job.Status)
|
||||
steps = append(steps, &api.ActionWorkflowStep{
|
||||
Name: step.Name,
|
||||
Number: int64(i),
|
||||
|
@ -954,7 +954,7 @@ func (*webhookNotifier) WorkflowJobStatusUpdate(ctx context.Context, repo *repo_
|
||||
org = convert.ToOrganization(ctx, organization.OrgFromUser(repo.Owner))
|
||||
}
|
||||
|
||||
status, _ := toActionStatus(job.Status)
|
||||
status, _ := convert.ToActionsStatus(job.Status)
|
||||
|
||||
convertedJob, err := convert.ToActionWorkflowJob(ctx, repo, job)
|
||||
if err != nil {
|
||||
@ -984,7 +984,7 @@ func (*webhookNotifier) WorkflowRunStatusUpdate(ctx context.Context, repo *repo_
|
||||
org = convert.ToOrganization(ctx, organization.OrgFromUser(repo.Owner))
|
||||
}
|
||||
|
||||
status, _ := toActionStatus(run.Status)
|
||||
status, _ := convert.ToActionsStatus(run.Status)
|
||||
|
||||
convertedRun, err := convert.ToActionWorkflowRun(repo, run)
|
||||
if err != nil {
|
||||
@ -1003,29 +1003,3 @@ func (*webhookNotifier) WorkflowRunStatusUpdate(ctx context.Context, repo *repo_
|
||||
log.Error("PrepareWebhooks: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func toActionStatus(status actions_model.Status) (string, string) {
|
||||
var action string
|
||||
var conclusion string
|
||||
switch status {
|
||||
// This is a naming conflict of the webhook between Gitea and GitHub Actions
|
||||
case actions_model.StatusWaiting:
|
||||
action = "queued"
|
||||
case actions_model.StatusBlocked:
|
||||
action = "waiting"
|
||||
case actions_model.StatusRunning:
|
||||
action = "in_progress"
|
||||
}
|
||||
if status.IsDone() {
|
||||
action = "completed"
|
||||
switch status {
|
||||
case actions_model.StatusSuccess:
|
||||
conclusion = "success"
|
||||
case actions_model.StatusCancelled:
|
||||
conclusion = "cancelled"
|
||||
case actions_model.StatusFailure:
|
||||
conclusion = "failure"
|
||||
}
|
||||
}
|
||||
return action, conclusion
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user