feat: add simple actions without integration to another code
All checks were successful
build / build (push) Successful in 2m23s
All checks were successful
build / build (push) Successful in 2m23s
This commit is contained in:
24
internal/actions/webhooks.go
Normal file
24
internal/actions/webhooks.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package actions
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
func SendWebhook(url string, data []byte) (int, error) {
|
||||
client := &http.Client{
|
||||
Timeout: 30 * time.Second,
|
||||
}
|
||||
req, err := http.NewRequest("POST", url, bytes.NewReader(data))
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
// #nosec G704 validating by admin
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return resp.StatusCode, nil
|
||||
}
|
||||
Reference in New Issue
Block a user