Skip to content

Commit

Permalink
QUick look
Browse files Browse the repository at this point in the history
Signed-off-by: Carlos Eduardo Arango Gutierrez <eduardoa@nvidia.com>
  • Loading branch information
ArangoGutierrez committed Feb 29, 2024
1 parent 2abb3b9 commit f5c535b
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions cmd/nv-ci-bot/retitle/retitle.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ func (m command) run(c *cli.Context) error {
m.log.Error(err, "Failed to get action context")
return err
}

var newTitle string
var issueNumber int
var issueNumber float64
if context.Event != nil {
if comment, ok := context.Event["comment"].(map[string]any); ok {
// Extract the comment body
if body, ok := comment["body"].(string); ok {
// Make sure they are requesting a re-title
if !retitleRe.MatchString(body) {
Expand All @@ -83,8 +83,9 @@ func (m command) run(c *cli.Context) error {
newTitle = getNewTitle(body)
}
}
// get the issue number
if issue, ok := context.Event["issue"].(map[string]any); ok {
if num, ok := issue["number"].(int); ok {
if num, ok := issue["number"].(float64); ok {
issueNumber = num
}
}
Expand All @@ -93,14 +94,14 @@ func (m command) run(c *cli.Context) error {
m.log.Info("Issue number", "number", issueNumber)

org, repo := context.Repo()
ghToken := action.Getenv("GITHUB_TOKEN")
ghToken := action.GetInput("GITHUB_TOKEN")
gh := github.NewClient(nil).WithAuthToken(ghToken)

// Update the title
req := &github.IssueRequest{
Title: &newTitle,
}
_, _, err = gh.Issues.Edit(c.Context, org, repo, issueNumber, req)
_, _, err = gh.Issues.Edit(c.Context, org, repo, int(issueNumber), req)
if err != nil {
m.log.Error(err, "Failed to update issue")
return err
Expand Down

0 comments on commit f5c535b

Please sign in to comment.