Skip to content

Add event.schedule context for schedule actions task#37320

Merged
silverwind merged 5 commits into
go-gitea:mainfrom
lunny:lunny/add_schedule_actions
Apr 21, 2026
Merged

Add event.schedule context for schedule actions task#37320
silverwind merged 5 commits into
go-gitea:mainfrom
lunny:lunny/add_schedule_actions

Conversation

@lunny
Copy link
Copy Markdown
Member

@lunny lunny commented Apr 20, 2026

Fix #35452

@lunny lunny requested a review from Zettat123 April 20, 2026 17:07
@lunny lunny added type/bug backport/v1.26 This PR should be backported to Gitea 1.26 labels Apr 20, 2026
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Apr 20, 2026
@lunny lunny requested a review from Copilot April 20, 2026 17:07
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses #35452 by ensuring the schedule cron expression is injected into the github.event payload for scheduled workflow runs, enabling conditions like ${{ github.event.schedule == '*/5 * * * *' }}.

Changes:

  • Pass the schedule spec string into scheduled run creation and inject it into the run’s EventPayload as schedule.
  • Add unit tests for the new payload-munging helper.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
services/actions/schedule_tasks.go Updates schedule task creation to enrich EventPayload with a schedule field derived from the spec string.
services/actions/schedule_tasks_test.go Adds tests around withScheduleInEventPayload behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread services/actions/schedule_tasks_test.go Outdated
Comment on lines +140 to +144
if err := json.Unmarshal([]byte(eventPayload), &event); err != nil {
return eventPayload
}

event["schedule"] = schedule
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

withScheduleInEventPayload will panic when eventPayload is the JSON literal "null": json.Unmarshal succeeds but sets the map to nil, and then event["schedule"] assignment panics. This can happen because schedule specs created via DetectAndHandleSchedules marshal a nil payload, resulting in "null" being stored. Also, when eventPayload is empty/whitespace, Unmarshal fails and the schedule is silently not added. Consider treating empty/"null" payloads as an empty object ({}), and after unmarshal defensively re-initialize the map if it is nil before setting the "schedule" field.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This review is right, who marked it as resolved ........

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "fix" to this review is just wrong f665654

@silverwind
Copy link
Copy Markdown
Member

silverwind commented Apr 21, 2026

Does this cover both github.event.schedule and gitea.event.schedule?

Also we should expand github.event in docs, I opened https://gitea.com/gitea/docs/issues/386.

@silverwind silverwind added docs-update-needed The document needs to be updated synchronously and removed docs-update-needed The document needs to be updated synchronously labels Apr 21, 2026
@lunny
Copy link
Copy Markdown
Member Author

lunny commented Apr 21, 2026

Does this cover both github.event.schedule and gitea.event.schedule?

Yes, Both.

Also we should expand github.event in docs, I opened gitea.com/gitea/docs/issues/386.

Yes.

Log unmarshal/marshal failures in withScheduleInEventPayload so
corrupt payloads are debuggable instead of silently falling back.
Rename the misleading "creates payload when empty" subtest, add a
malformed-JSON case, and drop the one-call eventPayloadAsMap helper.

Co-Authored-By: Claude (Opus 4.7) <noreply@anthropic.com>
@silverwind
Copy link
Copy Markdown
Member

Some cleanups done in 8a737be.

@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 21, 2026
@bircni bircni added this to the 1.26.1 milestone Apr 21, 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 21, 2026
@lunny lunny added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Apr 21, 2026
@bircni
Copy link
Copy Markdown
Member

bircni commented Apr 21, 2026

@lunny wanna merge?

@silverwind silverwind enabled auto-merge (squash) April 21, 2026 19:59
@silverwind silverwind merged commit f1644fc into go-gitea:main Apr 21, 2026
26 checks passed
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Apr 21, 2026
@lunny lunny deleted the lunny/add_schedule_actions branch April 21, 2026 21:09
@GiteaBot GiteaBot added the backport/done All backports for this PR have been created label Apr 21, 2026
silverwind added a commit that referenced this pull request Apr 21, 2026
Backport #37320 by @lunny

Fix #35452

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: Claude (Opus 4.7) <noreply@anthropic.com>
zjjhot added a commit to zjjhot/gitea that referenced this pull request Apr 22, 2026
* main: (25 commits)
  Add URL to `Learn more about blocking a user` (go-gitea#37355)
  fix: use TriggerEvent instead of Event in workflow runs API response for scheduled runs (go-gitea#37288)
  Add event.schedule context for schedule actions task (go-gitea#37320)
  Fix typos (go-gitea#37346)
  Fix an issue where changing an organization’s visibility caused problems when users had forked its repositories. (go-gitea#37324)
  Fail vite build on rolldown warnings via NODE_ENV=test (go-gitea#37270)
  Use modern "git update-index --cacheinfo" syntax to support more file names (go-gitea#37338)
  Fix URL related escaping for oauth2 (go-gitea#37334)
  When the requested arch rpm is missing fall back to noarch (go-gitea#37236)
  Fix `relative-time` error and improve global error handler (go-gitea#37241)
  Enhance styling in actions page (go-gitea#37323)
  fix(oauth): Error on auth sources with spaces (go-gitea#37327)
  Fix actions concurrency groups cross-branch leak (go-gitea#37311)
  Fix bug when accessing user badges (go-gitea#37321)
  Fix AppFullLink (go-gitea#37325)
  Update go js dependencies (go-gitea#37312)
  Update GitHub Actions to latest major versions (go-gitea#37313)
  Revert "Add WebKit to e2e test matrix (go-gitea#37298)" (go-gitea#37315)
  Add `form-fetch-action` to some forms, fix "fetch action" resp bug (go-gitea#37305)
  Move heatmap to first-party code (go-gitea#37262)
  ...
silverwind added a commit to silverwind/gitea that referenced this pull request Apr 23, 2026
* origin/main: (32 commits)
  fix: commit status reporting (go-gitea#37372)
  Support for Custom URI Schemes in OAuth2 Redirect URIs (go-gitea#37356)
  Fix cmd tests by mocking builtin paths (go-gitea#37369)
  chore: upgrade Go version in devcontainer image to 1.26 (go-gitea#37374)
  Fix button layout shift when collapsing file tree in editor (go-gitea#37363)
  Update `Block a user` form (go-gitea#37359)
  Remove IsValidExternalURL/IsAPIURL and use IsValidURL at call sites (go-gitea#37364)
  Add URL to `Learn more about blocking a user` (go-gitea#37355)
  fix: use TriggerEvent instead of Event in workflow runs API response for scheduled runs (go-gitea#37288)
  Add event.schedule context for schedule actions task (go-gitea#37320)
  Fix typos (go-gitea#37346)
  Fix an issue where changing an organization’s visibility caused problems when users had forked its repositories. (go-gitea#37324)
  Fail vite build on rolldown warnings via NODE_ENV=test (go-gitea#37270)
  Use modern "git update-index --cacheinfo" syntax to support more file names (go-gitea#37338)
  Fix URL related escaping for oauth2 (go-gitea#37334)
  When the requested arch rpm is missing fall back to noarch (go-gitea#37236)
  Fix `relative-time` error and improve global error handler (go-gitea#37241)
  Enhance styling in actions page (go-gitea#37323)
  fix(oauth): Error on auth sources with spaces (go-gitea#37327)
  Fix actions concurrency groups cross-branch leak (go-gitea#37311)
  ...

# Conflicts:
#	services/actions/commit_status.go
silverwind added a commit to silverwind/gitea that referenced this pull request Apr 23, 2026
* origin/main: (204 commits)
  fix: commit status reporting (go-gitea#37372)
  Support for Custom URI Schemes in OAuth2 Redirect URIs (go-gitea#37356)
  Fix cmd tests by mocking builtin paths (go-gitea#37369)
  chore: upgrade Go version in devcontainer image to 1.26 (go-gitea#37374)
  Fix button layout shift when collapsing file tree in editor (go-gitea#37363)
  Update `Block a user` form (go-gitea#37359)
  Remove IsValidExternalURL/IsAPIURL and use IsValidURL at call sites (go-gitea#37364)
  Add URL to `Learn more about blocking a user` (go-gitea#37355)
  fix: use TriggerEvent instead of Event in workflow runs API response for scheduled runs (go-gitea#37288)
  Add event.schedule context for schedule actions task (go-gitea#37320)
  Fix typos (go-gitea#37346)
  Fix an issue where changing an organization’s visibility caused problems when users had forked its repositories. (go-gitea#37324)
  Fail vite build on rolldown warnings via NODE_ENV=test (go-gitea#37270)
  Use modern "git update-index --cacheinfo" syntax to support more file names (go-gitea#37338)
  Fix URL related escaping for oauth2 (go-gitea#37334)
  When the requested arch rpm is missing fall back to noarch (go-gitea#37236)
  Fix `relative-time` error and improve global error handler (go-gitea#37241)
  Enhance styling in actions page (go-gitea#37323)
  fix(oauth): Error on auth sources with spaces (go-gitea#37327)
  Fix actions concurrency groups cross-branch leak (go-gitea#37311)
  ...

# Conflicts:
#	web_src/js/index-domready.ts
#	web_src/js/markup/content.ts
#	web_src/js/markup/refissue.ts
silverwind added a commit to silverwind/gitea that referenced this pull request Apr 23, 2026
* origin/main: (204 commits)
  fix: commit status reporting (go-gitea#37372)
  Support for Custom URI Schemes in OAuth2 Redirect URIs (go-gitea#37356)
  Fix cmd tests by mocking builtin paths (go-gitea#37369)
  chore: upgrade Go version in devcontainer image to 1.26 (go-gitea#37374)
  Fix button layout shift when collapsing file tree in editor (go-gitea#37363)
  Update `Block a user` form (go-gitea#37359)
  Remove IsValidExternalURL/IsAPIURL and use IsValidURL at call sites (go-gitea#37364)
  Add URL to `Learn more about blocking a user` (go-gitea#37355)
  fix: use TriggerEvent instead of Event in workflow runs API response for scheduled runs (go-gitea#37288)
  Add event.schedule context for schedule actions task (go-gitea#37320)
  Fix typos (go-gitea#37346)
  Fix an issue where changing an organization’s visibility caused problems when users had forked its repositories. (go-gitea#37324)
  Fail vite build on rolldown warnings via NODE_ENV=test (go-gitea#37270)
  Use modern "git update-index --cacheinfo" syntax to support more file names (go-gitea#37338)
  Fix URL related escaping for oauth2 (go-gitea#37334)
  When the requested arch rpm is missing fall back to noarch (go-gitea#37236)
  Fix `relative-time` error and improve global error handler (go-gitea#37241)
  Enhance styling in actions page (go-gitea#37323)
  fix(oauth): Error on auth sources with spaces (go-gitea#37327)
  Fix actions concurrency groups cross-branch leak (go-gitea#37311)
  ...

Co-Authored-By: Claude (Opus 4.7) <noreply@anthropic.com>

# Conflicts:
#	web_src/js/index-domready.ts
#	web_src/js/markup/content.ts
#	web_src/js/markup/refissue.ts
@wxiaoguang
Copy link
Copy Markdown
Contributor

bug Actions withScheduleInEventPayload PANIC #37447

yamz8 pushed a commit to kerneliushq/kernelius-forge-cli that referenced this pull request May 11, 2026
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [docker.gitea.com/gitea](https://github.com/go-gitea/gitea) | service | patch | `1.26.0` → `1.26.1` |

---

### Release Notes

<details>
<summary>go-gitea/gitea (docker.gitea.com/gitea)</summary>

### [`v1.26.1`](https://github.com/go-gitea/gitea/releases/tag/v1.26.1)

[Compare Source](go-gitea/gitea@v1.26.0...v1.26.1)

- BUGFIXES   \* Add event.schedule context for schedule actions task ([#&#8203;37320](go-gitea/gitea#37320)) ([#&#8203;37348](go-gitea/gitea#37348))   \* Fix an issue where changing an organization's visibility caused problems when users had forked its repositories. ([#&#8203;37324](go-gitea/gitea#37324)) ([#&#8203;37344](go-gitea/gitea#37344))   \* Use modern "git update-index --cacheinfo" syntax to support more file names ([#&#8203;37338](go-gitea/gitea#37338)) ([#&#8203;37343](go-gitea/gitea#37343))   \* Fix URL related escaping for oauth2 ([#&#8203;37334](go-gitea/gitea#37334)) ([#&#8203;37340](go-gitea/gitea#37340))   \* When the requested arch rpm is missing fall back to noarch ([#&#8203;37236](go-gitea/gitea#37236)) ([#&#8203;37339](go-gitea/gitea#37339))   \* Fix actions concurrency groups cross-branch leak ([#&#8203;37311](go-gitea/gitea#37311)) ([#&#8203;37331](go-gitea/gitea#37331))   \* Fix bug when accessing user badges ([#&#8203;37321](go-gitea/gitea#37321)) ([#&#8203;37329](go-gitea/gitea#37329))   \* Fix AppFullLink ([#&#8203;37325](go-gitea/gitea#37325)) ([#&#8203;37328](go-gitea/gitea#37328))   \* Fix container auth for public instance ([#&#8203;37290](go-gitea/gitea#37290)) ([#&#8203;37294](go-gitea/gitea#37294))   \* Enhance GetActionWorkflow to support fallback references ([#&#8203;37189](go-gitea/gitea#37189)) ([#&#8203;37283](go-gitea/gitea#37283))   \* Fix vite manifest update masking build errors ([#&#8203;37279](go-gitea/gitea#37279)) ([#&#8203;37310](go-gitea/gitea#37310))   \* Fix Mermaid diagrams failing when node labels contain line breaks ([#&#8203;37296](go-gitea/gitea#37296)) ([#&#8203;37299](go-gitea/gitea#37299))   \* Use TriggerEvent instead of Event in workflow runs API response for scheduled runs ([#&#8203;37288](go-gitea/gitea#37288)) [#&#8203;37360](go-gitea/gitea#37360)   \* Add URL to Learn more about blocking a user. ([#&#8203;37355](go-gitea/gitea#37355)) [#&#8203;37367](go-gitea/gitea#37367)   \* Fix button layout shift when collapsing file tree in editor ([#&#8203;37363](go-gitea/gitea#37363)) [#&#8203;37375](go-gitea/gitea#37375)   \* Fix org team assignee/reviewer lookups for team member permissions ([#&#8203;37365](go-gitea/gitea#37365)) [#&#8203;37391](go-gitea/gitea#37391)   \* Fix repo init README EOL ([#&#8203;37388](go-gitea/gitea#37388)) [#&#8203;37399](go-gitea/gitea#37399)   \* Fix: dump with default zip type produces uncompressed zip ([#&#8203;37401](https://github.com/go-gitea/gitea/issues/37401))[#&#8203;37402](https://github.com/go-gitea/gitea/issues/37402)

</details>

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xNDAuMCIsInVwZGF0ZWRJblZlciI6IjQzLjE0MC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

Reviewed-on: https://gitea.com/gitea/tea/pulls/968
Co-authored-by: Renovate Bot <renovate-bot@gitea.com>
Co-committed-by: Renovate Bot <renovate-bot@gitea.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/done All backports for this PR have been created backport/v1.26 This PR should be backported to Gitea 1.26 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.

Missing github.event.schedule when schedule event is triggered

6 participants