Skip to content

Commit

Permalink
feat: Add missing deployment_status properties (#55)
Browse files Browse the repository at this point in the history
* feat: Add missing deployment_status properties

- Add missing properties to DeploymentStatusEvent
- Add missing properties to WorkflowRun

Contributes to #54.

* feat: Add actor and triggering_actor

Add the `actor` and `triggering_actor` properties to WorkflowRun.

* feat: Add previous_attempt_url

- Add missing `previous_attempt_url` property.
- Sort properties according to the schema.

* feat: Add missing deployment properties

- Add missing properties/types for the `deployment` and `deployment_status` events.
- Use dedicated types for `deployment_status`.
- Add missing deployment event to `CheckRun`.
- Add missing `environment_url` and `log_url` properties to `DeploymentStatus`.
  • Loading branch information
martincostello committed Mar 31, 2022
1 parent a39fe36 commit 67d6930
Show file tree
Hide file tree
Showing 11 changed files with 258 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Octokit.Webhooks/Events/DeploymentEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,11 @@ public abstract record DeploymentEvent : WebhookEvent
{
[JsonPropertyName("deployment")]
public Models.DeploymentEvent.Deployment Deployment { get; init; } = null!;

[JsonPropertyName("workflow")]
public Models.Workflow? Workflow { get; init; } = null!;

[JsonPropertyName("workflow_run")]
public Models.DeploymentEvent.DeploymentWorkflowRun? WorkflowRun { get; init; } = null!;
}
}
9 changes: 9 additions & 0 deletions src/Octokit.Webhooks/Events/DeploymentStatusEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,14 @@ public abstract record DeploymentStatusEvent : WebhookEvent

[JsonPropertyName("deployment")]
public Models.DeploymentStatusEvent.Deployment Deployment { get; init; } = null!;

[JsonPropertyName("check_run")]
public Models.DeploymentEvent.DeploymentCheckRun? CheckRun { get; init; }

[JsonPropertyName("workflow_run")]
public Models.DeploymentEvent.DeploymentWorkflowRun? WorkflowRun { get; init; }

[JsonPropertyName("workflow")]
public Models.Workflow? Workflow { get; init; }
}
}
3 changes: 3 additions & 0 deletions src/Octokit.Webhooks/Models/CheckRunEvent/CheckRun.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,8 @@ public sealed record CheckRun

[JsonPropertyName("pull_requests")]
public IEnumerable<CheckRunPullRequest> PullRequests { get; init; } = null!;

[JsonPropertyName("deployment")]
public Deployment Deployment { get; init; } = null!;
}
}
49 changes: 49 additions & 0 deletions src/Octokit.Webhooks/Models/DeploymentEvent/DeploymentCheckRun.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
namespace Octokit.Webhooks.Models.DeploymentEvent
{
using System;
using System.Text.Json.Serialization;
using JetBrains.Annotations;
using Octokit.Webhooks.Converter;

[PublicAPI]
public sealed record DeploymentCheckRun
{
[JsonPropertyName("id")]
public long Id { get; init; }

[JsonPropertyName("name")]
public string Name { get; init; } = null!;

[JsonPropertyName("node_id")]
public string NodeId { get; init; } = null!;

[JsonPropertyName("head_sha")]
public string HeadSha { get; init; } = null!;

[JsonPropertyName("external_id")]
public string ExternalId { get; init; } = null!;

[JsonPropertyName("url")]
public string Url { get; init; } = null!;

[JsonPropertyName("html_url")]
public string HtmlUrl { get; init; } = null!;

[JsonPropertyName("details_url")]
public string DetailsUrl { get; init; } = null!;

[JsonPropertyName("status")]
public DeploymentCheckRunStatus Status { get; init; }

[JsonPropertyName("conclusion")]
public DeploymentCheckRunConclusion? Conclusion { get; init; }

[JsonPropertyName("started_at")]
[JsonConverter(typeof(DateTimeOffsetConverter))]
public DateTimeOffset StartedAt { get; init; }

[JsonPropertyName("completed_at")]
[JsonConverter(typeof(NullableDateTimeOffsetConverter))]
public DateTimeOffset? CompletedAt { get; init; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
namespace Octokit.Webhooks.Models.DeploymentEvent
{
using System.Runtime.Serialization;
using System.Text.Json.Serialization;

[JsonConverter(typeof(JsonStringEnumMemberConverter))]
public enum DeploymentCheckRunConclusion
{
[EnumMember(Value = "success")]
Success,
[EnumMember(Value = "failure")]
Failure,
[EnumMember(Value = "neutral")]
Neutral,
[EnumMember(Value = "cancelled")]
Cancelled,
[EnumMember(Value = "timed_out")]
TimedOut,
[EnumMember(Value = "actionRequired")]
ActionRequired,
[EnumMember(Value = "stale")]
Stale,
[EnumMember(Value = "skipped")]
Skipped,
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
namespace Octokit.Webhooks.Models.DeploymentEvent
{
using System.Runtime.Serialization;
using System.Text.Json.Serialization;

[JsonConverter(typeof(JsonStringEnumMemberConverter))]
public enum DeploymentCheckRunStatus
{
[EnumMember(Value = "requested")]
Requested,
[EnumMember(Value = "in_progress")]
InProgress,
[EnumMember(Value = "completed")]
Completed,
[EnumMember(Value = "queued")]
Queued,
[EnumMember(Value = "waiting")]
Waiting,
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
namespace Octokit.Webhooks.Models.DeploymentEvent
{
using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;
using JetBrains.Annotations;
using Octokit.Webhooks.Converter;
using Octokit.Webhooks.Models.CheckRunEvent;

[PublicAPI]
public sealed record DeploymentWorkflowRun
{
[JsonPropertyName("id")]
public long Id { get; init; }

[JsonPropertyName("name")]
public string Name { get; init; } = null!;

[JsonPropertyName("node_id")]
public string NodeId { get; init; } = null!;

[JsonPropertyName("head_branch")]
public string HeadBranch { get; init; } = null!;

[JsonPropertyName("head_sha")]
public string HeadSha { get; init; } = null!;

[JsonPropertyName("run_number")]
public long RunNumber { get; init; }

[JsonPropertyName("event")]
public string Event { get; init; } = null!;

[JsonPropertyName("status")]
public DeploymentWorkflowRunStatus? Status { get; init; }

[JsonPropertyName("conclusion")]
public DeploymentWorkflowRunConclusion? Conclusion { get; init; }

[JsonPropertyName("workflow_id")]
public long WorkflowId { get; init; }

[JsonPropertyName("check_suite_id")]
public long CheckSuiteId { get; init; }

[JsonPropertyName("check_suite_node_id")]
public string CheckSuiteNodeId { get; init; } = null!;

[JsonPropertyName("url")]
public string Url { get; init; } = null!;

[JsonPropertyName("html_url")]
public string HtmlUrl { get; init; } = null!;

[JsonPropertyName("pull_requests")]
public IEnumerable<CheckRunPullRequest> PullRequests { get; init; } = null!;

[JsonPropertyName("created_at")]
[JsonConverter(typeof(DateTimeOffsetConverter))]
public DateTimeOffset CreatedAt { get; init; }

[JsonPropertyName("updated_at")]
[JsonConverter(typeof(DateTimeOffsetConverter))]
public DateTimeOffset UpdatedAt { get; init; }

[JsonPropertyName("actor")]
public User Actor { get; init; } = null!;

[JsonPropertyName("triggering_actor")]
public User TriggeringActor { get; init; } = null!;

[JsonPropertyName("run_attempt")]
public long RunAttempt { get; init; }

[JsonPropertyName("run_started_at")]
[JsonConverter(typeof(DateTimeOffsetConverter))]
public DateTimeOffset RunStartedAt { get; init; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
namespace Octokit.Webhooks.Models.DeploymentEvent
{
using System.Runtime.Serialization;
using System.Text.Json.Serialization;

[JsonConverter(typeof(JsonStringEnumMemberConverter))]
public enum DeploymentWorkflowRunConclusion
{
[EnumMember(Value = "success")]
Success,
[EnumMember(Value = "failure")]
Failure,
[EnumMember(Value = "neutral")]
Neutral,
[EnumMember(Value = "cancelled")]
Cancelled,
[EnumMember(Value = "timed_out")]
TimedOut,
[EnumMember(Value = "action_required")]
ActionRequired,
[EnumMember(Value = "stale")]
Stale,
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
namespace Octokit.Webhooks.Models.DeploymentEvent
{
using System.Runtime.Serialization;
using System.Text.Json.Serialization;

[JsonConverter(typeof(JsonStringEnumMemberConverter))]
public enum DeploymentWorkflowRunStatus
{
[EnumMember(Value = "requested")]
Requested,
[EnumMember(Value = "in_progress")]
InProgress,
[EnumMember(Value = "completed")]
Completed,
[EnumMember(Value = "queued")]
Queued,
[EnumMember(Value = "waiting")]
Waiting,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ public sealed record DeploymentStatus
[JsonPropertyName("environment")]
public string Environment { get; init; } = null!;

[JsonPropertyName("environment_url")]
public string? EnvironmentUrl { get; init; }

[JsonPropertyName("log_url")]
public string? LogUrl { get; init; }

[JsonPropertyName("target_url")]
public string TargetUrl { get; init; } = null!;

Expand Down
16 changes: 16 additions & 0 deletions src/Octokit.Webhooks/Models/WorkflowRun.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,21 @@ public sealed record WorkflowRun

[JsonPropertyName("workflow_url")]
public string WorkflowUrl { get; init; } = null!;

[JsonPropertyName("run_attempt")]
public long RunAttempt { get; init; }

[JsonPropertyName("run_started_at")]
[JsonConverter(typeof(DateTimeOffsetConverter))]
public DateTimeOffset RunStartedAt { get; init; }

[JsonPropertyName("previous_attempt_url")]
public string? PreviousAttemptUrl { get; init; }

[JsonPropertyName("actor")]
public User Actor { get; init; } = null!;

[JsonPropertyName("triggering_actor")]
public User TriggeringActor { get; init; } = null!;
}
}

0 comments on commit 67d6930

Please sign in to comment.