From 28a310346d680651310367f2821c950a97f246f6 Mon Sep 17 00:00:00 2001 From: Joshua Oster-Morris Date: Thu, 3 Feb 2022 12:03:34 -0500 Subject: [PATCH 1/3] Add PRs to WorkflowRunPayload fixed #140 --- github/github_test.go | 2 +- github/payload.go | 25 ++++++++++++++++++++++++- testdata/github/workflow_run.json | 25 +++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 2 deletions(-) diff --git a/github/github_test.go b/github/github_test.go index 478efae..a37cf69 100644 --- a/github/github_test.go +++ b/github/github_test.go @@ -570,7 +570,7 @@ func TestWebhooks(t *testing.T) { filename: "../testdata/github/workflow_run.json", headers: http.Header{ "X-Github-Event": []string{"workflow_run"}, - "X-Hub-Signature": []string{"sha1=c54d046b1ce440bc3434c8de5ad73e0a630d7cbe"}, + "X-Hub-Signature": []string{"sha1=46c14317c062992de64d11e12a0bad91dd9c4f50"}, }, }, } diff --git a/github/payload.go b/github/payload.go index 0f46acc..36f25ef 100644 --- a/github/payload.go +++ b/github/payload.go @@ -6430,7 +6430,30 @@ type WorkflowRunPayload struct { CheckSuiteNodeID string `json:"check_suite_node_id"` URL string `json:"url"` HTMLURL string `json:"html_url"` - // PullRequests []interface{} `json:"pull_requests"` + PullRequests []struct { + ID int64 `json:"id"` + Number int64 `json:"number"` + URL string `json:"url"` + Head struct { + Ref string `json:"ref"` + Sha string `json:"sha"` + URL string `json:"url"` + Repo struct { + ID int64 `json:"id"` + Name string `json:"name"` + URL string `json:"url"` + } `json:"repo"` + } `json:"head"` + Base struct { + Ref string `json:"ref"` + Sha string `json:"sha"` + Repo struct { + ID int64 `json:"id"` + Name string `json:"name"` + URL string `json:"url"` + } `json:"repo"` + } `json:"base"` + } `json:"pull_requests"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` RunAttempt int64 `json:"run_attempt"` diff --git a/testdata/github/workflow_run.json b/testdata/github/workflow_run.json index ff3b090..e465c88 100644 --- a/testdata/github/workflow_run.json +++ b/testdata/github/workflow_run.json @@ -15,6 +15,31 @@ "check_suite_node_id": "1", "url": "https://api.github.com/users/baxterthehacker/", "html_url": "https://api.github.com/users/baxterthehacker/html_url", + "pull_requests": [ + { + "url": "https://api.github.com/repos/baxterthehacker/public-repo/pulls/43", + "id": 836659880, + "number": 43, + "head": { + "ref": "HeadBranch", + "sha": "d6b80f8411bdc1a44407ff20619a74068b03ea5a", + "repo": { + "id": 434328729, + "url": "https://api.github.com/repos/baxterthehacker/public-repo", + "name": "public-repo" + } + }, + "base": { + "ref": "master", + "sha": "959ab634fb1411f204b2be49b68236808d6b741c", + "repo": { + "id": 434328729, + "url": "https://api.github.com/repos/baxterthehacker/public-repo", + "name": "public-repo" + } + } + } + ], "created_at": "2015-05-05T23:40:12Z", "updated_at": "2015-05-05T23:40:30Z", "run_attempt": 1, From c0effc6c5ba04aa1a8294e1b7e3aff0d3c1a43a3 Mon Sep 17 00:00:00 2001 From: Joshua Oster-Morris Date: Thu, 3 Feb 2022 12:09:38 -0500 Subject: [PATCH 2/3] Extra field found --- github/payload.go | 1 - 1 file changed, 1 deletion(-) diff --git a/github/payload.go b/github/payload.go index 36f25ef..6c0c490 100644 --- a/github/payload.go +++ b/github/payload.go @@ -6437,7 +6437,6 @@ type WorkflowRunPayload struct { Head struct { Ref string `json:"ref"` Sha string `json:"sha"` - URL string `json:"url"` Repo struct { ID int64 `json:"id"` Name string `json:"name"` From 67108ae8abb43c6a9451fea29fe5e8bbfd394653 Mon Sep 17 00:00:00 2001 From: Joshua Oster-Morris Date: Mon, 19 Sep 2022 11:54:54 -0400 Subject: [PATCH 3/3] add referenced_workflows to workflow_run --- github/payload.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/github/payload.go b/github/payload.go index 6c0c490..ee941af 100644 --- a/github/payload.go +++ b/github/payload.go @@ -6453,6 +6453,11 @@ type WorkflowRunPayload struct { } `json:"repo"` } `json:"base"` } `json:"pull_requests"` + ReferencedWorkflows []struct { + Path string `json:"path"` + Ref string `json:"ref"` + Sha string `json:"sha"` + } `json:"referenced_workflows"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` RunAttempt int64 `json:"run_attempt"`