Skip to content

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
GiteaBot:backport-37288-v1.26
Open

fix: use TriggerEvent instead of Event in workflow runs API response for scheduled runs (#37288)#37360
GiteaBot wants to merge 1 commit intogo-gitea:release/v1.26from
GiteaBot:backport-37288-v1.26

Conversation

@GiteaBot
Copy link
Copy Markdown
Collaborator

Backport #37288 by @KalashThakare

Summary

Fixes #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:

Screenshot 2026-04-19 115642

After

event: "schedule" correctly returned for scheduled runs:

Screenshot 2026-04-19 121723

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.

…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>
@GiteaBot GiteaBot requested a review from lunny April 22, 2026 08:13
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Apr 22, 2026
@GiteaBot GiteaBot added this to the 1.26.1 milestone Apr 22, 2026
@GiteaBot GiteaBot requested a review from silverwind April 22, 2026 08:13
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Apr 22, 2026
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Apr 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants