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