Skip to content

Add workflow_run api + webhook #33964

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 82 commits into from
Jun 20, 2025
Merged
Changes from 1 commit
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
edb2459
wip event
ChristopherHX Mar 14, 2025
013a0af
wip
ChristopherHX Mar 17, 2025
e93f9d2
update comment
ChristopherHX Mar 17, 2025
6701375
add routes
ChristopherHX Mar 17, 2025
988cafe
remove duplicated code
ChristopherHX Mar 17, 2025
20f5d6e
use ToActionsStatus
ChristopherHX Mar 17, 2025
a178e4b
use cached task instance if available
ChristopherHX Mar 17, 2025
295bf45
cleanup and fix webhook type bug
ChristopherHX Mar 17, 2025
392baec
remove dead code
ChristopherHX Mar 17, 2025
fb8a221
Move GetActionWorkflow to convert
ChristopherHX Mar 17, 2025
ccb9dec
fixup
ChristopherHX Mar 17, 2025
658583a
Merge branch 'main' of https://github.com/go-gitea/gitea into workflo…
ChristopherHX Mar 17, 2025
da738ea
webhook deliver the workflow field
ChristopherHX Mar 17, 2025
171efe5
update context with name
ChristopherHX Mar 17, 2025
605ed19
invoke workflow_run
ChristopherHX Mar 17, 2025
c3f6f13
prevent endless workflow_run trigger
ChristopherHX Mar 17, 2025
ca6bbc6
wip
ChristopherHX Mar 17, 2025
875c774
wip test and fixes
ChristopherHX Mar 18, 2025
22bfd96
fix keda scaler compat
ChristopherHX Mar 18, 2025
6c9dae9
fix api result
ChristopherHX Mar 18, 2025
5588588
add missing translate keys
ChristopherHX Mar 18, 2025
5a0f4c9
add other webhook types
ChristopherHX Mar 21, 2025
6df1854
..
ChristopherHX Mar 21, 2025
a983d34
fix workflow_run action event processing
ChristopherHX Mar 21, 2025
b650ca9
Merge branch 'main' of https://github.com/go-gitea/gitea into workflo…
ChristopherHX Mar 21, 2025
8cfb047
fix lint
ChristopherHX Mar 21, 2025
8fd54f2
update swagger docu
ChristopherHX Mar 21, 2025
c43cb79
...
ChristopherHX Mar 21, 2025
23de934
add branches-ignore to workflow_run
ChristopherHX Mar 21, 2025
956556d
update comment
ChristopherHX Mar 21, 2025
bb85519
allow workflow_run for recusive depth of 5
ChristopherHX Mar 21, 2025
cdefda1
fix comment
ChristopherHX Mar 21, 2025
d404c60
Sync run status with db prior webhook delivery
ChristopherHX Mar 21, 2025
0940208
fix lint
ChristopherHX Mar 21, 2025
4629a68
fix comment
ChristopherHX Mar 21, 2025
9b3eb4c
change action of workflow_run to align
ChristopherHX Mar 21, 2025
500a9bf
Merge branch 'main' of https://github.com/go-gitea/gitea into workflo…
ChristopherHX Mar 21, 2025
5beb9ae
...
ChristopherHX Mar 21, 2025
8acd36b
Merge branch 'main' of https://github.com/go-gitea/gitea into workflo…
ChristopherHX Mar 27, 2025
4ae2a2b
Merge branch 'main' into workflow-webhook-api
ChristopherHX Apr 5, 2025
3c95213
Merge branch 'main' of https://github.com/go-gitea/gitea into pr/Chri…
ChristopherHX Apr 12, 2025
7a0bb03
reorder api
ChristopherHX Apr 12, 2025
896b24a
fix lint
ChristopherHX Apr 12, 2025
3e3be37
Merge branch 'main' of https://github.com/go-gitea/gitea into pr/Chri…
ChristopherHX May 2, 2025
37c96b0
fix workflow name in workflow payload
ChristopherHX May 2, 2025
8a7f930
fixup
ChristopherHX May 3, 2025
3f479a2
avoid breaking existing test by using different test repo
ChristopherHX May 3, 2025
f82178e
add more test and more level of runs / jobs access
ChristopherHX May 3, 2025
dfd27c1
fix swagger consistency
ChristopherHX May 3, 2025
1845ac7
cleanup
ChristopherHX May 3, 2025
0a5a6eb
sync
ChristopherHX May 3, 2025
27c9c27
fix tests
ChristopherHX May 3, 2025
48379a2
improve tests and fix bugs
ChristopherHX May 3, 2025
5be456b
add actor and triggerActor
ChristopherHX May 3, 2025
7c7bd1d
add headsha filter
ChristopherHX May 3, 2025
b0f5360
update swagger for head_sha
ChristopherHX May 3, 2025
d3981cc
move implementations to correct places
ChristopherHX May 3, 2025
0feed42
fix error message
ChristopherHX May 5, 2025
149aac6
Merge branch 'main' of https://github.com/go-gitea/gitea into pr/Chri…
ChristopherHX May 5, 2025
cb26830
Merge branch 'main' of https://github.com/go-gitea/gitea into pr/Chri…
ChristopherHX May 14, 2025
fe23a1d
...
ChristopherHX May 14, 2025
e7a8806
use id from input
ChristopherHX May 14, 2025
42ca070
fix regression, wrong parameter order
ChristopherHX May 15, 2025
b300a49
fix test regression after run deletion
ChristopherHX May 15, 2025
ddc6584
remove redundant type
ChristopherHX May 15, 2025
7d2cb14
Merge branch 'main' of https://github.com/go-gitea/gitea into pr/Chri…
ChristopherHX May 20, 2025
e732461
Merge branch 'main' of https://github.com/go-gitea/gitea into pr/Chri…
ChristopherHX May 28, 2025
4f06b23
add missing merge cruft
ChristopherHX May 28, 2025
8b0577e
remove unused func
ChristopherHX May 28, 2025
a6e55dd
Merge branch 'main' into workflow-webhook-api
ChristopherHX Jun 14, 2025
da7efb7
Merge branch 'main' of https://github.com/go-gitea/gitea into pr/Chri…
ChristopherHX Jun 15, 2025
b522893
Migrate tests
ChristopherHX Jun 15, 2025
28821a6
Use ctx.FormString / ctx.FormStrings to cache url values
ChristopherHX Jun 20, 2025
7a4de43
Notifier use ctx
ChristopherHX Jun 20, 2025
b0459c5
add comment to ListJobs with runID and check runID > 0
ChristopherHX Jun 20, 2025
2c5b34c
update comment ListJobs
ChristopherHX Jun 20, 2025
dff7576
Merge branch 'main' of https://github.com/go-gitea/gitea into pr/Chri…
ChristopherHX Jun 20, 2025
afbade4
Update code for new code style rules
ChristopherHX Jun 20, 2025
84e0ee1
fix ctx.ServerError
wxiaoguang Jun 20, 2025
e47fc94
NotifyWorkflowRunStatusUpdateWithReload
wxiaoguang Jun 20, 2025
d0a903d
add some comments to FormString
wxiaoguang Jun 20, 2025
2e3c4ab
use PathEscapeSegments for tree path
wxiaoguang Jun 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Sync run status with db prior webhook delivery
* fixes status glitch of webhook
* e.g. queued for cancel
* e.g. completed for rerun
  • Loading branch information
ChristopherHX committed Mar 21, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit d404c60b73490936e0339065ac2061b4dfb9168e
17 changes: 13 additions & 4 deletions routers/web/repo/actions/view.go
Original file line number Diff line number Diff line change
@@ -459,6 +459,8 @@
}

actions_service.CreateCommitStatus(ctx, job)
// Sync run status with db
job.Run = nil
_ = job.LoadAttributes(ctx)
notify_service.WorkflowRunStatusUpdate(ctx, job.Run.Repo, job.Run.TriggerUser, job.Run)
notify_service.WorkflowJobStatusUpdate(ctx, job.Run.Repo, job.Run.TriggerUser, job, nil)
@@ -564,6 +566,9 @@
}
if len(updatedjobs) > 0 {
job := updatedjobs[0]
// Sync run status with db
job.Run = nil
job.LoadAttributes(ctx)

Check failure on line 571 in routers/web/repo/actions/view.go

GitHub Actions / lint-backend

Error return value of `job.LoadAttributes` is not checked (errcheck)

Check failure on line 571 in routers/web/repo/actions/view.go

GitHub Actions / lint-go-gogit

Error return value of `job.LoadAttributes` is not checked (errcheck)

Check failure on line 571 in routers/web/repo/actions/view.go

GitHub Actions / lint-go-windows

Error return value of `job.LoadAttributes` is not checked (errcheck)
notify_service.WorkflowRunStatusUpdate(ctx, job.Run.Repo, job.Run.TriggerUser, job.Run)
}
ctx.JSON(http.StatusOK, struct{}{})
@@ -607,15 +612,19 @@

actions_service.CreateCommitStatus(ctx, jobs...)

for _, job := range updatedjobs {
_ = job.LoadAttributes(ctx)
notify_service.WorkflowJobStatusUpdate(ctx, job.Run.Repo, job.Run.TriggerUser, job, nil)
}
if len(updatedjobs) > 0 {
job := updatedjobs[0]
// Sync run status with db
job.Run = nil
job.LoadAttributes(ctx)

Check failure on line 619 in routers/web/repo/actions/view.go

GitHub Actions / lint-backend

Error return value of `job.LoadAttributes` is not checked (errcheck)

Check failure on line 619 in routers/web/repo/actions/view.go

GitHub Actions / lint-go-gogit

Error return value of `job.LoadAttributes` is not checked (errcheck)

Check failure on line 619 in routers/web/repo/actions/view.go

GitHub Actions / lint-go-windows

Error return value of `job.LoadAttributes` is not checked (errcheck)
notify_service.WorkflowRunStatusUpdate(ctx, job.Run.Repo, job.Run.TriggerUser, job.Run)
}

for _, job := range updatedjobs {
_ = job.LoadAttributes(ctx)
notify_service.WorkflowJobStatusUpdate(ctx, job.Run.Repo, job.Run.TriggerUser, job, nil)
}

ctx.JSON(http.StatusOK, struct{}{})
}

6 changes: 3 additions & 3 deletions services/actions/clear_tasks.go
Original file line number Diff line number Diff line change
@@ -127,11 +127,11 @@ func CancelAbandonedJobs(ctx context.Context) error {
}
CreateCommitStatus(ctx, job)
if updated {
// Sync run status with db
job.Run = nil
_ = job.LoadAttributes(ctx)
notify_service.WorkflowJobStatusUpdate(ctx, job.Run.Repo, job.Run.TriggerUser, job, nil)
if job.Run != nil {
notify_service.WorkflowRunStatusUpdate(ctx, job.Run.Repo, job.Run.TriggerUser, job.Run)
}
notify_service.WorkflowRunStatusUpdate(ctx, job.Run.Repo, job.Run.TriggerUser, job.Run)
}
}

5 changes: 4 additions & 1 deletion services/actions/job_emitter.go
Original file line number Diff line number Diff line change
@@ -80,14 +80,17 @@
}
if len(jobs) > 0 {
runUpdated := true
run := jobs[0].Run
for _, job := range jobs {
if !job.Status.IsDone() {
runUpdated = false
break
}
}
if runUpdated {
// Sync run status with db
jobs[0].Run = nil
jobs[0].LoadAttributes(ctx)

Check failure on line 92 in services/actions/job_emitter.go

GitHub Actions / lint-backend

Error return value of `(*code.gitea.io/gitea/models/actions.ActionRunJob).LoadAttributes` is not checked (errcheck)

Check failure on line 92 in services/actions/job_emitter.go

GitHub Actions / lint-go-gogit

Error return value of `(*code.gitea.io/gitea/models/actions.ActionRunJob).LoadAttributes` is not checked (errcheck)

Check failure on line 92 in services/actions/job_emitter.go

GitHub Actions / lint-go-windows

Error return value of `(*code.gitea.io/gitea/models/actions.ActionRunJob).LoadAttributes` is not checked (errcheck)
run := jobs[0].Run
notify_service.WorkflowRunStatusUpdate(ctx, run.Repo, run.TriggerUser, run)
}
}