This repository has been archived by the owner on Aug 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature(main): add pr comment code (#12)
Signed-off-by: cuisongliu <cuisongliu@qq.com>
- Loading branch information
1 parent
c6bc0b9
commit ef85a32
Showing
18 changed files
with
404 additions
and
174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.