Skip to content

Commit f3fc2f3

Browse files
committed
Add more webhook fields
1 parent bdf0c1d commit f3fc2f3

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

modules/structs/repo_actions.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ type ActionArtifactsResponse struct {
101101
type ActionWorkflowStep struct {
102102
Name string `json:"name"`
103103
Number int64 `json:"number"`
104+
Status string `json:"status"`
104105
Conclusion string `json:"conclusion,omitempty"`
105106
// swagger:strfmt date-time
106107
StartedAt time.Time `json:"started_at,omitempty"`
@@ -118,9 +119,10 @@ type ActionWorkflowJob struct {
118119
RunAttempt int64 `json:"run_attempt"`
119120
HeadSha string `json:"head_sha"`
120121
HeadBranch string `json:"head_branch,omitempty"`
122+
Status string `json:"status"`
121123
Conclusion string `json:"conclusion,omitempty"`
122-
RunnerID int64 `json:"runner_id"`
123-
RunnerName string `json:"runner_name"`
124+
RunnerID int64 `json:"runner_id,omitempty"`
125+
RunnerName string `json:"runner_name,omitempty"`
124126
Steps []*ActionWorkflowStep `json:"steps"`
125127
// swagger:strfmt date-time
126128
CreatedAt time.Time `json:"created_at"`

services/webhook/notifier.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"context"
88

99
actions_model "code.gitea.io/gitea/models/actions"
10+
"code.gitea.io/gitea/models/db"
1011
git_model "code.gitea.io/gitea/models/git"
1112
issues_model "code.gitea.io/gitea/models/issues"
1213
"code.gitea.io/gitea/models/organization"
@@ -960,17 +961,22 @@ func (*webhookNotifier) CreateWorkflowJob(ctx context.Context, repo *repo_model.
960961
return
961962
}
962963

963-
action, conclusion := toActionStatus(job.Status)
964+
status, conclusion := toActionStatus(job.Status)
964965
var runnerID int64
966+
var runnerName string
965967
var steps []*api.ActionWorkflowStep
966968

967969
if task != nil {
968970
runnerID = task.RunnerID
971+
if runner, ok, _ := db.GetByID[actions_model.ActionRunner](ctx, runnerID); ok {
972+
runnerName = runner.Name
973+
}
969974
for i, step := range task.Steps {
970-
_, stepConclusion := toActionStatus(job.Status)
975+
stepStatus, stepConclusion := toActionStatus(job.Status)
971976
steps = append(steps, &api.ActionWorkflowStep{
972977
Name: step.Name,
973978
Number: int64(i),
979+
Status: stepStatus,
974980
Conclusion: stepConclusion,
975981
StartedAt: step.Started.AsTime().UTC(),
976982
CompletedAt: step.Stopped.AsTime().UTC(),
@@ -979,7 +985,7 @@ func (*webhookNotifier) CreateWorkflowJob(ctx context.Context, repo *repo_model.
979985
}
980986

981987
if err := PrepareWebhooks(ctx, source, webhook_module.HookEventWorkflowJob, &api.WorkflowJobPayload{
982-
Action: action,
988+
Action: status,
983989
WorkflowJob: &api.ActionWorkflowJob{
984990
ID: job.ID,
985991
RunID: job.RunID,
@@ -989,8 +995,10 @@ func (*webhookNotifier) CreateWorkflowJob(ctx context.Context, repo *repo_model.
989995
RunAttempt: job.Attempt,
990996
HeadSha: job.Run.CommitSHA,
991997
HeadBranch: git.RefName(job.Run.Ref).BranchName(),
998+
Status: status,
992999
Conclusion: conclusion,
9931000
RunnerID: runnerID,
1001+
RunnerName: runnerName,
9941002
Steps: steps,
9951003
CreatedAt: job.Created.AsTime().UTC(),
9961004
StartedAt: job.Started.AsTime().UTC(),

0 commit comments

Comments
 (0)