mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-11 19:04:35 +00:00
Save meta to explore service (#82)
This commit is contained in:
2
.github/workflows/docs.yml
vendored
2
.github/workflows/docs.yml
vendored
@@ -58,6 +58,8 @@ jobs:
|
||||
working-directory: services
|
||||
run: |
|
||||
go run cmd/docgen/main.go .
|
||||
env:
|
||||
MICRO_ADMIN_TOKEN: ${{ secrets.MICRO_ADMIN_TOKEN }}
|
||||
|
||||
- name: Deploy
|
||||
if: github.ref == 'refs/heads/master'
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
@@ -16,6 +18,33 @@ import (
|
||||
"github.com/stoewer/go-strcase"
|
||||
)
|
||||
|
||||
func saveMeta(service, readme, openapijson string) error {
|
||||
client := &http.Client{}
|
||||
|
||||
//Encode the data
|
||||
postBody, _ := json.Marshal(map[string]string{
|
||||
"serviceName": service,
|
||||
"readme": readme,
|
||||
"openAPIJSON": openapijson,
|
||||
})
|
||||
rbody := bytes.NewBuffer(postBody)
|
||||
|
||||
//Leverage Go's HTTP Post function to make request
|
||||
req, err := http.NewRequest("POST", "https://api.m3o.com/explore/SaveMeta", rbody)
|
||||
|
||||
// Add auth headers here if needed
|
||||
req.Header.Add("Authorization", `Bearer `+os.Getenv("MICRO_ADMIN_TOKEN"))
|
||||
resp, err := client.Do(req)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
io.Copy(ioutil.Discard, resp.Body)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
const (
|
||||
postContentPath = "docs/hugo-tania/site/content/post"
|
||||
docsURL = "services.m3o.com"
|
||||
@@ -92,6 +121,13 @@ func main() {
|
||||
fmt.Println("Failed to unmarshal", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
err = saveMeta(serviceName, string(dat), string(js))
|
||||
if err != nil {
|
||||
fmt.Println("Failed to save meta to explore service", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
err = saveSpec(dat, contentDir, serviceName, spec)
|
||||
if err != nil {
|
||||
fmt.Println("Failed to save to spec file", err)
|
||||
|
||||
Reference in New Issue
Block a user