Skip to content

Commit

Permalink
feature(main): add rebot code
Browse files Browse the repository at this point in the history
  • Loading branch information
cuisongliu committed Apr 20, 2023
1 parent 7f6d522 commit bcbb48f
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 7 deletions.
14 changes: 9 additions & 5 deletions .github/gh-bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,16 @@ release:

message:
success: |
🤖 says: The action {{.Body}} finished successfully 🎉
🤖 says: Hooray! The action {{.Body}} has been completed successfully. 🎉
format_error: |
🤖 says: ‼️ The action format error, please check the format of this action.
🤖 says: ‼️ There is a formatting issue with the action, kindly verify the action's format.
permission_error: |
🤖 says: ‼️ The action no has permission to trigger.
🤖 says: ‼️ The action doesn't have permission to trigger.
release_error: |
🤖 says: ‼️ The action release error.
🤖 says: ‼️ Release action failed.
Error details: {{.Error}}
changelog_error: |
🤖 says: ‼️ The action changelog error.
🤖 says: ‼️ Changelog action encountered an error.
Error details: {{.Error}}
14 changes: 14 additions & 0 deletions pkg/bot/bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,17 @@ func GetChangelogComment() string {
}
return strings.Join([]string{types.GlobalsBotConfig.GetPrefix(), "changelog"}, types.GlobalsBotConfig.GetSpe())
}

//approve
//lgtm
//hold
//triage
///ok-to-test

//assign cc cc
//cc xx xx xx
//area
//------

//issue
//assign
6 changes: 4 additions & 2 deletions pkg/workflow/send_msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ import (
)

type sender struct {
Body string
Body string
Error string
}

func (s *sender) sendMsgToIssue(msgKey string, actionURL ...string) error {
Expand All @@ -34,7 +35,8 @@ func (s *sender) sendMsgToIssue(msgKey string, actionURL ...string) error {
if b {
out := bytes.NewBuffer(nil)
_ = v.Execute(out, map[string]interface{}{
"Body": s.Body,
"Body": s.Body,
"Error": s.Error,
})
msg = out.String()
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/workflow/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package workflow

import (
"fmt"
"github.com/cuisongliu/logger"
"github.com/labring-actions/gh-rebot/pkg/bot"
"github.com/labring-actions/gh-rebot/pkg/gh"
Expand All @@ -38,13 +39,15 @@ func (c *workflow) Release() error {
if len(data) == 2 && utils.ValidateVersion(data[1]) {
err := gh.Tag(data[1])
if err != nil {
c.sender.Error = err.Error()
return c.sender.sendMsgToIssue("release_error")
}
action, err := gh.CheckRelease(data[1])
if err != nil {
return err
}
if !action.IsSuccess {
c.sender.Error = fmt.Sprintf("release action status is %s,action conclusion is %s", action.Status, action.Conclusion)
return c.sender.sendMsgToIssue("release_error", action.URL)
}
if err = c.sender.sendMsgToIssue("success", action.URL); err != nil {
Expand All @@ -68,6 +71,7 @@ func (c *workflow) Changelog() error {
if len(data) == 1 {
err := gh.Changelog(types.GlobalsBotConfig.Changelog.Reviewers)
if err != nil {
c.sender.Error = err.Error()
return c.sender.sendMsgToIssue("changelog_error")
}
return c.sender.sendMsgToIssue("success")
Expand Down

0 comments on commit bcbb48f

Please sign in to comment.