Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deployment task is arbitrary string value #2413

Merged
merged 1 commit into from
Jul 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Octokit.Tests/Models/DeploymentTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public void CanSerialize()
};
var deserialized = new SimpleJsonSerializer().Serialize(deployment);

Assert.Equal(@"{""ref"":""ref"",""task"":""deploy"",""payload"":{""environment"":""production""}}", deserialized);
Assert.Equal(@"{""ref"":""ref"",""payload"":{""environment"":""production""}}", deserialized);
}

[Fact]
Expand Down Expand Up @@ -50,7 +50,8 @@ public void CanDeserialize()
""created_at"": ""2012-07-20T01:19:13Z"",
""updated_at"": ""2012-07-20T01:19:13Z"",
""description"": ""Deploy request from hubot"",
""statuses_url"": ""https://api.github.com/repos/octocat/example/deployments/1/statuses""
""statuses_url"": ""https://api.github.com/repos/octocat/example/deployments/1/statuses"",
""task"": ""deploy""
}";

var actual = new SimpleJsonSerializer().Deserialize<Deployment>(json);
Expand All @@ -63,6 +64,7 @@ public void CanDeserialize()
Assert.Equal(DateTimeOffset.Parse("2012-07-20T01:19:13Z"), actual.UpdatedAt);
Assert.Equal("Deploy request from hubot", actual.Description);
Assert.Equal("https://api.github.com/repos/octocat/example/deployments/1/statuses", actual.StatusesUrl);
Assert.Equal("deploy", actual.Task);
}
}
}
25 changes: 2 additions & 23 deletions Octokit/Models/Request/NewDeployment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,9 @@ public NewDeployment(string @ref)

/// <summary>
/// Gets or sets the optional task used to specify a task to execute, e.g. deploy or deploy:migrations.
/// Default: deploy
/// Default if not specified: deploy
/// </summary>
/// <value>
/// The task.
/// </value>
public DeployTask Task { get; set; }
public string Task { get; set; }

/// <summary>
/// Merges the default branch into the requested deployment branch if true;
Expand Down Expand Up @@ -95,22 +92,4 @@ internal string DebuggerDisplay
}
}
}

/// <summary>
/// The types of deployments tasks that are available.
/// </summary>
public enum DeployTask
{
/// <summary>
/// Deploy everything (default)
/// </summary>
[Parameter(Value = "deploy")]
Deploy,

/// <summary>
/// Deploy migrations only.
/// </summary>
[Parameter(Value = "deploy:migrations")]
DeployMigrations
}
}
8 changes: 7 additions & 1 deletion Octokit/Models/Response/Deployment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class Deployment
{
public Deployment() { }

public Deployment(int id, string nodeId, string sha, string url, User creator, IReadOnlyDictionary<string, string> payload, DateTimeOffset createdAt, DateTimeOffset updatedAt, string description, string statusesUrl, bool transientEnvironment, bool productionEnvironment)
public Deployment(int id, string nodeId, string sha, string url, User creator, IReadOnlyDictionary<string, string> payload, DateTimeOffset createdAt, DateTimeOffset updatedAt, string description, string statusesUrl, bool transientEnvironment, bool productionEnvironment, string task)
{
Id = id;
NodeId = nodeId;
Expand All @@ -27,6 +27,7 @@ public Deployment(int id, string nodeId, string sha, string url, User creator, I
StatusesUrl = statusesUrl;
TransientEnvironment = transientEnvironment;
ProductionEnvironment = productionEnvironment;
Task = task;
}

/// <summary>
Expand Down Expand Up @@ -89,6 +90,11 @@ public Deployment(int id, string nodeId, string sha, string url, User creator, I
/// </summary>
public bool ProductionEnvironment { get; protected set; }

/// <summary>
/// Specifies a task to execute (e.g., deploy or deploy:migrations)
/// </summary>
public string Task { get; protected set; }

internal string DebuggerDisplay
{
get
Expand Down