Attempt to add more logging
All checks were successful
Create and publish a Docker image / build-and-push-image (push) Successful in 55s

This commit is contained in:
Alexandre Bruyant 2024-01-06 19:54:00 +01:00
parent 51c755a2c7
commit d2824ce7e4

View File

@ -22,6 +22,8 @@ type AddResponse struct {
}
func main() {
githubactions.Infof("Checking inputs...")
// Check inputs
path := githubactions.GetInput("path_to_add")
if path == "" {
@ -53,6 +55,8 @@ func main() {
githubactions.Fatalf("%v is not a directory", path)
}
githubactions.Infof("Inputs OK")
body, writer := io.Pipe()
// TODO: URL
@ -68,6 +72,7 @@ func main() {
req.Header.Add("Content-Type", mwriter.FormDataContentType())
err = filepath.Walk(path, func(innerPath string, info fs.FileInfo, err error) error {
githubactions.Infof("Reading %v", innerPath)
if err != nil {
return err
}
@ -100,12 +105,14 @@ func main() {
}
}()
githubactions.Infof("Calling node API")
client := &http.Client{}
res, err := client.Do(req)
if err != nil {
githubactions.Fatalf(err.Error())
}
githubactions.Infof("Reading response")
resBody, err := io.ReadAll(res.Body)
if err != nil {
githubactions.Fatalf(err.Error())
@ -114,5 +121,7 @@ func main() {
var ipfsAddResponse AddResponse
json.Unmarshal(resBody, &ipfsAddResponse)
githubactions.Infof("Upload size is %v", ipfsAddResponse.Bytes)
githubactions.Infof("CID is %v", ipfsAddResponse.Hash)
githubactions.SetOutput("cid", ipfsAddResponse.Hash)
}