Skip to content

Commit

Permalink
add WebhookEventType::Schedule variant
Browse files Browse the repository at this point in the history
Signed-off-by: Jean Mertz <[email protected]>
  • Loading branch information
JeanMertz authored and XAMPPRocky committed Aug 15, 2023
1 parent cfb05b7 commit b0cf074
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
9 changes: 9 additions & 0 deletions src/models/webhook_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,12 @@ pub enum WebhookEventType {
/// **Note:** This event is deprecated. see the
/// [`DependabotAlert`](WebhookEventType::DependabotAlert) event instead.
RepositoryVulnerabilityAlert,
/// The schedule event allows you to trigger a workflow at a scheduled time.
///
/// You can schedule a workflow to run at specific UTC times using POSIX cron syntax. Scheduled
/// workflows run on the latest commit on the default or base branch. The shortest interval you
/// can run scheduled workflows is once every 5 minutes.
Schedule,
/// This event occurs when there is activity relating to a secret scanning alert. For more
/// information about secret scanning, see "About secret scanning."
///
Expand Down Expand Up @@ -898,6 +904,9 @@ impl WebhookEventType {
serde_json::from_value(data)?,
)))
}
WebhookEventType::Schedule => Ok(WebhookEventPayload::Schedule(Box::new(
serde_json::from_value(data)?,
))),
WebhookEventType::SecretScanningAlert => Ok(WebhookEventPayload::SecretScanningAlert(
Box::new(serde_json::from_value(data)?),
)),
Expand Down
9 changes: 6 additions & 3 deletions src/models/webhook_events/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ mod repository_advisory;
mod repository_dispatch;
mod repository_import;
mod repository_vulnerability_alert;
mod schedule;
mod secret_scanning_alert;
mod secret_scanning_alert_location;
mod security_advisory;
Expand All @@ -77,9 +78,10 @@ pub use self::{
pull_request::*, pull_request_review::*, pull_request_review_comment::*,
pull_request_review_thread::*, push::*, registry_package::*, release::*, repository::*,
repository_advisory::*, repository_dispatch::*, repository_import::*,
repository_vulnerability_alert::*, secret_scanning_alert::*, secret_scanning_alert_location::*,
security_advisory::*, security_and_analysis::*, sponsorship::*, star::*, status::*, team::*,
team_add::*, watch::*, workflow_dispatch::*, workflow_job::*, workflow_run::*,
repository_vulnerability_alert::*, schedule::*, secret_scanning_alert::*,
secret_scanning_alert_location::*, security_advisory::*, security_and_analysis::*,
sponsorship::*, star::*, status::*, team::*, team_add::*, watch::*, workflow_dispatch::*,
workflow_job::*, workflow_run::*,
};

use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -141,6 +143,7 @@ pub enum WebhookEventPayload {
RepositoryDispatch(Box<RepositoryDispatchWebhookEventPayload>),
RepositoryImport(Box<RepositoryImportWebhookEventPayload>),
RepositoryVulnerabilityAlert(Box<RepositoryVulnerabilityAlertWebhookEventPayload>),
Schedule(Box<ScheduleWebhookEventPayload>),
SecretScanningAlert(Box<SecretScanningAlertWebhookEventPayload>),
SecretScanningAlertLocation(Box<SecretScanningAlertLocationWebhookEventPayload>),
SecurityAdvisory(Box<SecurityAdvisoryWebhookEventPayload>),
Expand Down
8 changes: 8 additions & 0 deletions src/models/webhook_events/payload/schedule.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ScheduleWebhookEventPayload {
pub schedule: String,
pub workflow: String,
}

0 comments on commit b0cf074

Please sign in to comment.