From 3160b64591cb02fece1c3f3b1384b1949d2f74a9 Mon Sep 17 00:00:00 2001 From: John Boyes Date: Wed, 13 Sep 2023 21:29:34 +0300 Subject: [PATCH] Revert "Revert #386 (#393)" (#400) This reverts commit f7377adc97752df42da96fa1355978c64393934c. That commit reverted #386 as a precautionary measure, while [investigating a potential bug][1]. It turns out [that there was no bug][2], though, so this commit reverts that revert. [1]: https://github.com/agilepathway/label-checker/issues/392 [2]: https://github.com/agilepathway/label-checker/issues/392#issuecomment-1714321629 --- internal/github/action.go | 6 ++++-- internal/github/action_test.go | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/internal/github/action.go b/internal/github/action.go index 69f704bf..5dec0c80 100644 --- a/internal/github/action.go +++ b/internal/github/action.go @@ -105,7 +105,9 @@ func (a *Action) repositoryName() string { func (a *Action) pullRequestNumber() int { event := struct { - PullRequestNumber int `json:"number"` + PullRequest struct { + Number int `json:"number"` + } `json:"pull_request"` }{} githubEventJSONFile, err := os.Open(filepath.Clean(os.Getenv("GITHUB_EVENT_PATH"))) panic.IfError(err) @@ -113,7 +115,7 @@ func (a *Action) pullRequestNumber() int { byteValue, _ := ioutil.ReadAll(githubEventJSONFile) panic.IfError(json.Unmarshal(byteValue, &event)) - return event.PullRequestNumber + return event.PullRequest.Number } func (a *Action) outputResult(result string) { diff --git a/internal/github/action_test.go b/internal/github/action_test.go index ad20e8cb..c4e661d7 100644 --- a/internal/github/action_test.go +++ b/internal/github/action_test.go @@ -273,7 +273,7 @@ func checkLabels() (int, *bytes.Buffer, *bytes.Buffer) { } func setPullRequestNumber(prNumber int) { - githubEventJSON := []byte(fmt.Sprintf(`{ "number": %d }`, prNumber)) + githubEventJSON := []byte(fmt.Sprintf(`{ "pull_request": { "number": %d } }`, prNumber)) os.WriteFile(gitHubEventFullPath(), githubEventJSON, os.ModePerm) //nolint }