Skip to content

Commit

Permalink
leveraging github-sdk typing
Browse files Browse the repository at this point in the history
  • Loading branch information
amenocal committed Jul 23, 2024
1 parent c6854f2 commit 1dc8352
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion internal/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package api

import (
"context"
"encoding/json"
"errors"
"fmt"
"io"
Expand Down Expand Up @@ -263,10 +264,22 @@ func UploadAssetViaURL(uploadURL string, asset *github.ReleaseAsset) error {
}

func WriteToIssue(issueNumber int, comment string) error {
githubContext := os.Getenv("GITHUB_CONTEXT")
if githubContext == "" {
return fmt.Errorf("GITHUB_CONTEXT is not set or empty")
}

var issueEvent github.IssueEvent

err := json.Unmarshal([]byte(githubContext), &issueEvent)
if err != nil {
return fmt.Errorf("error unmarshalling GITHUB_CONTEXT: %v", err)
}
//client := newGHRestClient(viper.GetString("TARGET_TOKEN"), "")

//ctx := context.WithValue(context.Background(), github.SleepUntilPrimaryRateLimitResetWhenRateLimited, true)
fmt.Printf("github context: %v", os.Getenv("GITHUB_CONTEXT"))
//fmt.Printf("github context: %v", os.Getenv("GITHUB_CONTEXT"))
fmt.Printf("github Issue Number: %v", issueEvent.Issue.Number)
fmt.Printf("comment: %v", comment)
//_, _, err := client.Issues.CreateComment(ctx, viper.Get("TARGET_ORGANIZATION").(string), viper.Get("REPOSITORY").(string), issueNumber, &github.IssueComment{Body: &comment})
// if err != nil {
Expand Down

0 comments on commit 1dc8352

Please sign in to comment.