From 8fd01e279856c83debc6397e1e2c1a3c6ba1fe60 Mon Sep 17 00:00:00 2001 From: CrispyBaguette Date: Mon, 8 Jan 2024 07:53:00 +0100 Subject: [PATCH] output CID --- main.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index 17d13b6..07c2c63 100644 --- a/main.go +++ b/main.go @@ -167,13 +167,22 @@ func main() { githubactions.Debugf("Response: %v", string(resBody)) d := json.NewDecoder(res.Body) + addResponses := make([]*AddResponse, 0) for { - var ipfsAddResponse []AddResponse - if err := d.Decode(&ipfsAddResponse); err == io.EOF { + var addResponse AddResponse + if err := d.Decode(&addResponse); err == io.EOF { break } else if err != nil { githubactions.Warningf("Failed to unmarshal response: %v", fmt.Errorf("%w", err)) } - githubactions.Debugf("Unmarshaled response: %v", ipfsAddResponse) + githubactions.Debugf("Unmarshaled response: %v", addResponse) + addResponses = append(addResponses, &addResponse) + } + + for _, addResponse := range addResponses { + if (*addResponse).Name == path { + githubactions.SetOutput("cid", addResponse.Hash) + break + } } }