Skip to content

Commit

Permalink
Use PR number from pull_request object (#386)
Browse files Browse the repository at this point in the history
Fix #385
  • Loading branch information
piotrekkr authored Aug 26, 2023
1 parent d251488 commit 149b0c2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions internal/github/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,17 @@ 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)
defer githubEventJSONFile.Close() //nolint
byteValue, _ := ioutil.ReadAll(githubEventJSONFile)
panic.IfError(json.Unmarshal(byteValue, &event))

return event.PullRequestNumber
return event.PullRequest.Number
}

func (a *Action) outputResult(result string) {
Expand Down
2 changes: 1 addition & 1 deletion internal/github/action_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 149b0c2

Please sign in to comment.