Skip to content

Commit d00a78f

Browse files
authored
Add WorkflowRun and Workflow to DeploymentEvent (#2755)
1 parent 0c10d67 commit d00a78f

File tree

4 files changed

+218
-2
lines changed

4 files changed

+218
-2
lines changed

github/event_types.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,10 @@ type DeployKeyEvent struct {
165165
//
166166
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#deployment
167167
type DeploymentEvent struct {
168-
Deployment *Deployment `json:"deployment,omitempty"`
169-
Repo *Repository `json:"repository,omitempty"`
168+
Deployment *Deployment `json:"deployment,omitempty"`
169+
Repo *Repository `json:"repository,omitempty"`
170+
Workflow *Workflow `json:"workflow,omitempty"`
171+
WorkflowRun *WorkflowRun `json:"workflow_run,omitempty"`
170172

171173
// The following fields are only populated by Webhook events.
172174
Sender *User `json:"sender,omitempty"`

github/event_types_test.go

Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5674,6 +5674,98 @@ func TestDeploymentEvent_Marshal(t *testing.T) {
56745674
},
56755675
SuspendedAt: &Timestamp{referenceTime},
56765676
},
5677+
Workflow: &Workflow{
5678+
ID: Int64(1),
5679+
NodeID: String("nid"),
5680+
Name: String("n"),
5681+
Path: String("p"),
5682+
State: String("s"),
5683+
CreatedAt: &Timestamp{referenceTime},
5684+
UpdatedAt: &Timestamp{referenceTime},
5685+
URL: String("u"),
5686+
HTMLURL: String("h"),
5687+
BadgeURL: String("b"),
5688+
},
5689+
WorkflowRun: &WorkflowRun{
5690+
ID: Int64(1),
5691+
Name: String("n"),
5692+
NodeID: String("nid"),
5693+
HeadBranch: String("hb"),
5694+
HeadSHA: String("hs"),
5695+
RunNumber: Int(1),
5696+
RunAttempt: Int(1),
5697+
Event: String("e"),
5698+
Status: String("s"),
5699+
Conclusion: String("c"),
5700+
WorkflowID: Int64(1),
5701+
URL: String("u"),
5702+
HTMLURL: String("h"),
5703+
PullRequests: []*PullRequest{
5704+
{
5705+
URL: String("u"),
5706+
ID: Int64(1),
5707+
Number: Int(1),
5708+
Head: &PullRequestBranch{
5709+
Ref: String("r"),
5710+
SHA: String("s"),
5711+
Repo: &Repository{
5712+
ID: Int64(1),
5713+
URL: String("s"),
5714+
Name: String("n"),
5715+
},
5716+
},
5717+
Base: &PullRequestBranch{
5718+
Ref: String("r"),
5719+
SHA: String("s"),
5720+
Repo: &Repository{
5721+
ID: Int64(1),
5722+
URL: String("u"),
5723+
Name: String("n"),
5724+
},
5725+
},
5726+
},
5727+
},
5728+
CreatedAt: &Timestamp{referenceTime},
5729+
UpdatedAt: &Timestamp{referenceTime},
5730+
RunStartedAt: &Timestamp{referenceTime},
5731+
JobsURL: String("j"),
5732+
LogsURL: String("l"),
5733+
CheckSuiteURL: String("c"),
5734+
ArtifactsURL: String("a"),
5735+
CancelURL: String("c"),
5736+
RerunURL: String("r"),
5737+
PreviousAttemptURL: String("p"),
5738+
HeadCommit: &HeadCommit{
5739+
Message: String("m"),
5740+
Author: &CommitAuthor{
5741+
Name: String("n"),
5742+
Email: String("e"),
5743+
Login: String("l"),
5744+
},
5745+
URL: String("u"),
5746+
Distinct: Bool(false),
5747+
SHA: String("s"),
5748+
ID: String("i"),
5749+
TreeID: String("tid"),
5750+
Timestamp: &Timestamp{referenceTime},
5751+
Committer: &CommitAuthor{
5752+
Name: String("n"),
5753+
Email: String("e"),
5754+
Login: String("l"),
5755+
},
5756+
},
5757+
WorkflowURL: String("w"),
5758+
Repository: &Repository{
5759+
ID: Int64(1),
5760+
URL: String("u"),
5761+
Name: String("n"),
5762+
},
5763+
HeadRepository: &Repository{
5764+
ID: Int64(1),
5765+
URL: String("u"),
5766+
Name: String("n"),
5767+
},
5768+
},
56775769
}
56785770

56795771
want := `{
@@ -5813,6 +5905,98 @@ func TestDeploymentEvent_Marshal(t *testing.T) {
58135905
"url": "u"
58145906
},
58155907
"suspended_at": ` + referenceTimeStr + `
5908+
},
5909+
"workflow": {
5910+
"id": 1,
5911+
"node_id": "nid",
5912+
"name": "n",
5913+
"path": "p",
5914+
"state": "s",
5915+
"created_at": ` + referenceTimeStr + `,
5916+
"updated_at": ` + referenceTimeStr + `,
5917+
"url": "u",
5918+
"html_url": "h",
5919+
"badge_url": "b"
5920+
},
5921+
"workflow_run": {
5922+
"id": 1,
5923+
"name": "n",
5924+
"node_id": "nid",
5925+
"head_branch": "hb",
5926+
"head_sha": "hs",
5927+
"run_number": 1,
5928+
"run_attempt": 1,
5929+
"event": "e",
5930+
"status": "s",
5931+
"conclusion": "c",
5932+
"workflow_id": 1,
5933+
"url": "u",
5934+
"html_url": "h",
5935+
"pull_requests": [
5936+
{
5937+
"id": 1,
5938+
"number": 1,
5939+
"url": "u",
5940+
"head": {
5941+
"ref": "r",
5942+
"sha": "s",
5943+
"repo": {
5944+
"id": 1,
5945+
"name": "n",
5946+
"url": "s"
5947+
}
5948+
},
5949+
"base": {
5950+
"ref": "r",
5951+
"sha": "s",
5952+
"repo": {
5953+
"id": 1,
5954+
"name": "n",
5955+
"url": "u"
5956+
}
5957+
}
5958+
}
5959+
],
5960+
"created_at": ` + referenceTimeStr + `,
5961+
"updated_at": ` + referenceTimeStr + `,
5962+
"run_started_at": ` + referenceTimeStr + `,
5963+
"jobs_url": "j",
5964+
"logs_url": "l",
5965+
"check_suite_url": "c",
5966+
"artifacts_url": "a",
5967+
"cancel_url": "c",
5968+
"rerun_url": "r",
5969+
"previous_attempt_url": "p",
5970+
"head_commit": {
5971+
"message": "m",
5972+
"author": {
5973+
"name": "n",
5974+
"email": "e",
5975+
"username": "l"
5976+
},
5977+
"url": "u",
5978+
"distinct": false,
5979+
"sha": "s",
5980+
"id": "i",
5981+
"tree_id": "tid",
5982+
"timestamp": ` + referenceTimeStr + `,
5983+
"committer": {
5984+
"name": "n",
5985+
"email": "e",
5986+
"username": "l"
5987+
}
5988+
},
5989+
"workflow_url": "w",
5990+
"repository": {
5991+
"id": 1,
5992+
"name": "n",
5993+
"url": "u"
5994+
},
5995+
"head_repository": {
5996+
"id": 1,
5997+
"name": "n",
5998+
"url": "u"
5999+
}
58166000
}
58176001
}`
58186002

github/github-accessors.go

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

github/github-accessors_test.go

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)