Skip to content
This repository has been archived by the owner on Aug 26, 2023. It is now read-only.

Commit

Permalink
feature(main): add pr comment code (#12)
Browse files Browse the repository at this point in the history
Signed-off-by: cuisongliu <cuisongliu@qq.com>
  • Loading branch information
cuisongliu authored Jun 7, 2023
1 parent c6bc0b9 commit ef85a32
Show file tree
Hide file tree
Showing 18 changed files with 404 additions and 174 deletions.
4 changes: 1 addition & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,4 @@ RUN apk --no-cache add jq bash curl git git-lfs github-cli

COPY gh-rebot /usr/bin/

ENTRYPOINT ["/usr/bin/gh-rebot"]

CMD ["--help"]
ENTRYPOINT ["/usr/bin/gh-rebot","action"]
9 changes: 9 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: "Gh Rebot for Sealos"
description: "Add some rebot command for sealos"
author: "cuisongliu"
runs:
using: 'docker'
image: 'Dockerfile'
branding:
icon: 'git-pull-request'
color: 'green'
55 changes: 55 additions & 0 deletions cmd/action.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
Copyright © 2023 NAME HERE <EMAIL ADDRESS>
*/
package cmd

import (
"fmt"
"github.com/cuisongliu/logger"
"github.com/labring/gh-rebot/pkg/action"
"github.com/labring/gh-rebot/pkg/setup"
"os"

"github.com/spf13/cobra"
)

// actionCmd represents the action command
var actionCmd = &cobra.Command{
Use: "action",
Run: func(cmd *cobra.Command, args []string) {
actionType, err := action.GetEnvFromAction("type")
if err != nil {
logger.Error(err)
os.Exit(1)
}
switch actionType {
case "/comment":
err = action.CommentEngine()
case "pr_comment":
err = action.PRComment()
default:
err = fmt.Errorf("not support action type")
}
if err != nil {
logger.Error(err)
os.Exit(1)
}
},
}

func init() {
cobra.OnInitialize(func() {
setup.Setup(cfgFile)
})
rootCmd.AddCommand(actionCmd)

// Here you will define your flags and configuration settings.

// Cobra supports Persistent Flags which will work for this command
// and all subcommands, e.g.:
// actionCmd.PersistentFlags().String("foo", "", "A help for foo")

// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
// actionCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}
74 changes: 0 additions & 74 deletions cmd/comment.go

This file was deleted.

3 changes: 2 additions & 1 deletion cmd/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package cmd

import (
"github.com/cuisongliu/logger"
"github.com/labring/gh-rebot/pkg/setup"
"github.com/labring/gh-rebot/pkg/webhook"

"github.com/spf13/cobra"
Expand All @@ -23,7 +24,7 @@ var webhookCmd = &cobra.Command{

func init() {
cobra.OnInitialize(func() {
checkToken()
setup.Setup(cfgFile)
})
rootCmd.AddCommand(webhookCmd)

Expand Down
29 changes: 12 additions & 17 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,29 @@ require (
github.com/gin-gonic/gin v1.9.0
github.com/gorilla/websocket v1.5.0
github.com/hashicorp/go-version v1.6.0
github.com/onsi/ginkgo v1.16.5
github.com/onsi/gomega v1.23.0
github.com/pkg/errors v0.9.1
github.com/spf13/cobra v1.6.1
k8s.io/apimachinery v0.26.2
k8s.io/client-go v0.26.2
sigs.k8s.io/yaml v1.3.0
)

require k8s.io/api v0.26.2
require (
github.com/google/go-github/v39 v39.2.0
golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b
sigs.k8s.io/kustomize/kyaml v0.14.2
)

require (
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/bytedance/sonic v1.8.0 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-errors/errors v1.4.2 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.20.0 // indirect
github.com/go-openapi/swag v0.19.14 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.1 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.11.2 // indirect
Expand All @@ -42,6 +42,7 @@ require (
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/gnostic v0.5.7-v3refs // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/gofuzz v1.1.0 // indirect
github.com/google/uuid v1.1.2 // indirect
github.com/huandu/xstrings v1.3.3 // indirect
Expand All @@ -51,14 +52,12 @@ require (
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.0.9 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
github.com/mailru/easyjson v0.7.6 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/mitchellh/copystructure v1.0.0 // indirect
github.com/mitchellh/reflectwalk v1.0.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/nxadm/tail v1.4.8 // indirect
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
github.com/shopspring/decimal v1.2.0 // indirect
github.com/spf13/cast v1.3.1 // indirect
Expand All @@ -68,19 +67,15 @@ require (
golang.org/x/arch v0.0.0-20210923205945-b76863e36670 // indirect
golang.org/x/crypto v0.5.0 // indirect
golang.org/x/net v0.7.0 // indirect
golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/term v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/klog/v2 v2.80.1 // indirect
k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 // indirect
k8s.io/kube-openapi v0.0.0-20230109183929-3758b55a6596 // indirect
k8s.io/utils v0.0.0-20221107191617-1a15be271d1d // indirect
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
Expand Down
Loading

0 comments on commit ef85a32

Please sign in to comment.