fix: use TriggerEvent instead of Event in workflow runs API response for scheduled runs (#37288)#37360
Open
GiteaBot wants to merge 1 commit intogo-gitea:release/v1.26from
Open
fix: use TriggerEvent instead of Event in workflow runs API response for scheduled runs (#37288)#37360GiteaBot wants to merge 1 commit intogo-gitea:release/v1.26from
GiteaBot wants to merge 1 commit intogo-gitea:release/v1.26from
Conversation
…for scheduled runs (go-gitea#37288) ## Summary Fixes go-gitea#37252 The `/api/v1/repos/{owner}/{repo}/actions/runs` endpoint was returning `event: "push"` for workflow runs triggered by `schedule:` (cron), instead of `event: "schedule"`. ## Root Cause `ActionRun` has two separate fields: - `Event` — the workflow registration event (e.g. `push`, set when the workflow file was first pushed) - `TriggerEvent` — the actual event that triggered the run (e.g. `schedule`) `ToActionWorkflowRun` in `services/convert/action.go` was serializing `run.Event` into the API response instead of `run.TriggerEvent`, causing scheduled runs to be indistinguishable from push events via the API. This was already asymmetric — the tasks/jobs API correctly used `TriggerEvent`. ## Fix Changed `ToActionWorkflowRun` to use `run.TriggerEvent` for the `event` field in the API response, consistent with how the jobs API works. ## Before `event: "push"` returned for all scheduled runs: <img width="1112" height="191" alt="Screenshot 2026-04-19 115642" src="https://github.com/user-attachments/assets/c0a169f5-bbd9-4f5d-9474-e4c3795110e4" /> ## After `event: "schedule"` correctly returned for scheduled runs: <img width="890" height="166" alt="Screenshot 2026-04-19 121723" src="https://github.com/user-attachments/assets/860e99ac-0935-4a43-86a1-7b60f8113480" /> ## Testing - Added unit test `TestToActionWorkflowRun_UsesTriggerEvent` in `services/convert/action_test.go` that explicitly verifies the API returns `TriggerEvent` and not `Event` for a scheduled run. - Manually verified via the API against a live Gitea instance with a `cron: "* * * * *"` workflow. --------- Co-authored-by: Nicolas <bircni@icloud.com>
silverwind
approved these changes
Apr 22, 2026
lunny
approved these changes
Apr 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport #37288 by @KalashThakare
Summary
Fixes #37252
The
/api/v1/repos/{owner}/{repo}/actions/runsendpoint was returningevent: "push"for workflow runs triggered byschedule:(cron), insteadof
event: "schedule".Root Cause
ActionRunhas two separate fields:Event— the workflow registration event (e.g.push, set when the workflow file was first pushed)TriggerEvent— the actual event that triggered the run (e.g.schedule)ToActionWorkflowRuninservices/convert/action.gowas serializingrun.Eventinto the API response instead ofrun.TriggerEvent, causingscheduled runs to be indistinguishable from push events via the API.
This was already asymmetric — the tasks/jobs API correctly used
TriggerEvent.Fix
Changed
ToActionWorkflowRunto userun.TriggerEventfor theeventfield in the API response, consistent with how the jobs API works.
Before
event: "push"returned for all scheduled runs:After
event: "schedule"correctly returned for scheduled runs:Testing
TestToActionWorkflowRun_UsesTriggerEventinservices/convert/action_test.gothat explicitly verifies the APIreturns
TriggerEventand notEventfor a scheduled run.cron: "* * * * *"workflow.