fix: pipeline fixes
This commit is contained in:
parent
e12834bc14
commit
b195a1dcfd
3 changed files with 68 additions and 51 deletions
1
.github/workflows/release.yml
vendored
1
.github/workflows/release.yml
vendored
|
|
@ -91,6 +91,7 @@ jobs:
|
|||
run: |
|
||||
npx \
|
||||
-p semantic-release \
|
||||
-p semantic-release-replace-plugin \
|
||||
-p @semantic-release/commit-analyzer \
|
||||
-p @semantic-release/release-notes-generator \
|
||||
-p @semantic-release/changelog \
|
||||
|
|
|
|||
|
|
@ -68,6 +68,11 @@
|
|||
],
|
||||
"@semantic-release/release-notes-generator",
|
||||
"@semantic-release/changelog",
|
||||
"@semantic-release/git"
|
||||
[
|
||||
"@semantic-release/git",
|
||||
{
|
||||
"assets": ["CHANGELOG.md", "README.md", "action.yml", ".github/workflows/example.yml", ".github/workflows/release.yml"]
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
|
|
|
|||
111
main.go
111
main.go
|
|
@ -4,6 +4,8 @@ import (
|
|||
"bytes"
|
||||
_ "embed"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"text/template"
|
||||
|
|
@ -42,6 +44,65 @@ func main() {
|
|||
data.CardID = uuid.NewString()
|
||||
data.Add = ""
|
||||
|
||||
getData(&data)
|
||||
|
||||
webhook := githubactions.GetInput("webhook")
|
||||
if webhook == "" {
|
||||
githubactions.Fatalf("Missing input 'webhook'")
|
||||
os.Exit(1)
|
||||
}
|
||||
webhook = fmt.Sprintf("%s&threadKey=notify%s&messageReplyOption=REPLY_MESSAGE_FALLBACK_TO_NEW_THREAD", webhook, data.ActionID)
|
||||
|
||||
giturl := githubactions.GetInput("giturl")
|
||||
if giturl == "" {
|
||||
githubactions.Fatalf("Missing input 'giturl'")
|
||||
os.Exit(1)
|
||||
}
|
||||
data.GitURL = giturl
|
||||
|
||||
body := githubactions.GetInput("event_body")
|
||||
data.EventBody = body
|
||||
|
||||
githubactions.Infof("using URL: %s", webhook)
|
||||
// fmt.Println("URL:> ", webhook)
|
||||
|
||||
// var jsonStr = []byte(fmt.Sprintf(data, project, commit, branch, status, actionid))
|
||||
|
||||
jsonStr, err := card(data)
|
||||
if err != nil {
|
||||
githubactions.Fatalf("err %s", err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// log.Printf("retrieved data: %s", string(jsonStr))
|
||||
|
||||
req, err := http.NewRequest("POST", webhook, bytes.NewBuffer(jsonStr))
|
||||
if err != nil {
|
||||
githubactions.Fatalf("error %s", err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
req.Header.Set("Content-Type", "application/json; charset=UTF-8")
|
||||
client := &http.Client{}
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
githubactions.Fatalf("error %s", err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
defer func(Body io.ReadCloser) {
|
||||
err := Body.Close()
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
}(resp.Body)
|
||||
fmt.Println("response Status:", resp.Status)
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
githubactions.Infof("json: %s", jsonStr)
|
||||
githubactions.Fatalf("response: %+v\n", resp)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
func getData(data *templateData) {
|
||||
prj, ok := os.LookupEnv("FORGEJO_REPOSITORY")
|
||||
if ok {
|
||||
data.Project = prj
|
||||
|
|
@ -84,56 +145,6 @@ func main() {
|
|||
os.Exit(1)
|
||||
}
|
||||
data.ActionID = actionid
|
||||
|
||||
webhook := githubactions.GetInput("webhook")
|
||||
if webhook == "" {
|
||||
githubactions.Fatalf("Missing input 'webhook'")
|
||||
os.Exit(1)
|
||||
}
|
||||
webhook = fmt.Sprintf("%s&threadKey=notify%s&messageReplyOption=REPLY_MESSAGE_FALLBACK_TO_NEW_THREAD", webhook, data.ActionID)
|
||||
|
||||
giturl := githubactions.GetInput("giturl")
|
||||
if giturl == "" {
|
||||
githubactions.Fatalf("Missing input 'giturl'")
|
||||
os.Exit(1)
|
||||
}
|
||||
data.GitURL = giturl
|
||||
|
||||
body := githubactions.GetInput("event_body")
|
||||
data.EventBody = body
|
||||
|
||||
githubactions.Infof("using URL: %s", webhook)
|
||||
// fmt.Println("URL:> ", webhook)
|
||||
|
||||
// var jsonStr = []byte(fmt.Sprintf(data, project, commit, branch, status, actionid))
|
||||
|
||||
jsonStr, err := card(data)
|
||||
if err != nil {
|
||||
githubactions.Fatalf("error %s", err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// log.Printf("retrieved data: %s", string(jsonStr))
|
||||
|
||||
req, err := http.NewRequest("POST", webhook, bytes.NewBuffer(jsonStr))
|
||||
if err != nil {
|
||||
githubactions.Fatalf("error %s", err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
req.Header.Set("Content-Type", "application/json; charset=UTF-8")
|
||||
client := &http.Client{}
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
githubactions.Fatalf("error %s", err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
fmt.Println("response Status:", resp.Status)
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
githubactions.Infof("json: %s", jsonStr)
|
||||
githubactions.Fatalf("response: %+v\n", resp)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
func card(d templateData) ([]byte, error) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue