mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-20 20:07:03 +01:00
[ACTIONS] on.schedule: the event is always "schedule"
handleSchedules() is called every time an event is received and will check the content of the main branch to (re)create scheduled events. There is no reason why intput.Event will be relevant when the schedule workflow runs. (cherry picked from commit9a712bb276
) (cherry picked from commit41af36da81
) (cherry picked from commitbb83604fa2
) (cherry picked from commit65e4503a7a
) (cherry picked from commite562b6f7a0
)
This commit is contained in:
parent
86f4d1871e
commit
aca2ae2390
6 changed files with 15 additions and 1 deletions
|
@ -22,6 +22,7 @@ const (
|
||||||
GithubEventRelease = "release"
|
GithubEventRelease = "release"
|
||||||
GithubEventPullRequestComment = "pull_request_comment"
|
GithubEventPullRequestComment = "pull_request_comment"
|
||||||
GithubEventGollum = "gollum"
|
GithubEventGollum = "gollum"
|
||||||
|
GithubEventSchedule = "schedule"
|
||||||
)
|
)
|
||||||
|
|
||||||
// canGithubEventMatch check if the input Github event can match any Gitea event.
|
// canGithubEventMatch check if the input Github event can match any Gitea event.
|
||||||
|
@ -34,6 +35,9 @@ func canGithubEventMatch(eventName string, triggedEvent webhook_module.HookEvent
|
||||||
case GithubEventGollum:
|
case GithubEventGollum:
|
||||||
return triggedEvent == webhook_module.HookEventWiki
|
return triggedEvent == webhook_module.HookEventWiki
|
||||||
|
|
||||||
|
case GithubEventSchedule:
|
||||||
|
return triggedEvent == webhook_module.HookEventSchedule
|
||||||
|
|
||||||
case GithubEventIssues:
|
case GithubEventIssues:
|
||||||
switch triggedEvent {
|
switch triggedEvent {
|
||||||
case webhook_module.HookEventIssues,
|
case webhook_module.HookEventIssues,
|
||||||
|
|
|
@ -153,6 +153,7 @@ func detectMatched(gitRepo *git.Repository, commit *git.Commit, triggedEvent web
|
||||||
|
|
||||||
switch triggedEvent {
|
switch triggedEvent {
|
||||||
case // events with no activity types
|
case // events with no activity types
|
||||||
|
webhook_module.HookEventSchedule,
|
||||||
webhook_module.HookEventCreate,
|
webhook_module.HookEventCreate,
|
||||||
webhook_module.HookEventDelete,
|
webhook_module.HookEventDelete,
|
||||||
webhook_module.HookEventFork,
|
webhook_module.HookEventFork,
|
||||||
|
|
|
@ -118,6 +118,13 @@ func TestDetectMatched(t *testing.T) {
|
||||||
yamlOn: "on: gollum",
|
yamlOn: "on: gollum",
|
||||||
expected: true,
|
expected: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
desc: "HookEventSchedue(schedule) matches GithubEventSchedule(schedule)",
|
||||||
|
triggedEvent: webhook_module.HookEventSchedule,
|
||||||
|
payload: nil,
|
||||||
|
yamlOn: "on: schedule",
|
||||||
|
expected: true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
|
|
|
@ -31,6 +31,7 @@ const (
|
||||||
HookEventRepository HookEventType = "repository"
|
HookEventRepository HookEventType = "repository"
|
||||||
HookEventRelease HookEventType = "release"
|
HookEventRelease HookEventType = "release"
|
||||||
HookEventPackage HookEventType = "package"
|
HookEventPackage HookEventType = "package"
|
||||||
|
HookEventSchedule HookEventType = "schedule"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Event returns the HookEventType as an event string
|
// Event returns the HookEventType as an event string
|
||||||
|
|
|
@ -455,7 +455,7 @@ func handleSchedules(
|
||||||
TriggerUserID: input.Doer.ID,
|
TriggerUserID: input.Doer.ID,
|
||||||
Ref: input.Repo.DefaultBranch,
|
Ref: input.Repo.DefaultBranch,
|
||||||
CommitSHA: commit.ID.String(),
|
CommitSHA: commit.ID.String(),
|
||||||
Event: input.Event,
|
Event: webhook_module.HookEventType(api.HookScheduleCreated),
|
||||||
EventPayload: string(p),
|
EventPayload: string(p),
|
||||||
Specs: schedules,
|
Specs: schedules,
|
||||||
Content: dwf.Content,
|
Content: dwf.Content,
|
||||||
|
|
|
@ -112,6 +112,7 @@ func CreateScheduleTask(ctx context.Context, cron *actions_model.ActionSchedule)
|
||||||
Ref: cron.Ref,
|
Ref: cron.Ref,
|
||||||
CommitSHA: cron.CommitSHA,
|
CommitSHA: cron.CommitSHA,
|
||||||
Event: cron.Event,
|
Event: cron.Event,
|
||||||
|
TriggerEvent: string(webhook_module.HookEventSchedule),
|
||||||
EventPayload: cron.EventPayload,
|
EventPayload: cron.EventPayload,
|
||||||
ScheduleID: cron.ID,
|
ScheduleID: cron.ID,
|
||||||
Status: actions_model.StatusWaiting,
|
Status: actions_model.StatusWaiting,
|
||||||
|
|
Loading…
Reference in a new issue