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

Commit

Permalink
Repo support (#38)
Browse files Browse the repository at this point in the history
* feature(main):  add issue_renew action for action repo_support

Signed-off-by: cuisongliu <[email protected]>

* feature(main):  add issue_renew action for action repo_support

Signed-off-by: cuisongliu <[email protected]>

---------

Signed-off-by: cuisongliu <[email protected]>
  • Loading branch information
cuisongliu authored Jun 20, 2023
1 parent 348acd1 commit 098f349
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test-issue-renew.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
SEALOS_ISSUE_BODYFILE: "README.md"
SEALOS_ISSUE_LABEL: "dayly-report"
SEALOS_ISSUE_TYPE: "day"
SEALOS_ISSUE_REPO: "labring/gh-rebot"
GH_TOKEN: "${{ secrets.GH_PAT }}"
- run: |
echo "output is ${{ env.SEALOS_ISSUE_NUMBER }}"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ message:
- `SEALOS_ISREPLY: "true"` # 是否回复,根据当前的comment的内容追加

- [x] issue自动创建
> 该功能v0.0.7-rc3支持
> 该功能v0.0.7支持

入参:

Expand Down
9 changes: 8 additions & 1 deletion pkg/action/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,14 @@ func GetEnvFromAction(key string) (string, error) {
return val, nil
}

func getRepo() (string, string, error) {
func getRepo(r string) (string, string, error) {
if r != "" {
split := strings.Split(r, "/")
if len(split) != 2 {
return "", "", fmt.Errorf("repo format error")
}
return split[0], split[1], nil
}
repo := os.Getenv("GITHUB_REPOSITORY") // 获取环境变量GITHUB_REF
if repo == "" {
return "", "", fmt.Errorf("not found GITHUB_REPOSITORY")
Expand Down
2 changes: 1 addition & 1 deletion pkg/action/action_comment_reply.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func CommentReply() error {
comment = strings.Join([]string{replyBody, comment}, "\r\n\r\n")
}

owner, repo, err := getRepo()
owner, repo, err := getRepo("")
if err != nil {
return err
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/action/action_issue_renew.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ func IssueRenew() error {
default:
issueTitle = issueTitle + " " + utils.FormatDay(time.Now())
}
issueRepo, _ := GetEnvFromAction("issue_repo")

owner, repo, err := getRepo()
owner, repo, err := getRepo(issueRepo)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/action/action_pr_comment.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func PRComment() error {
if err != nil {
return err
}
owner, repo, err := getRepo()
owner, repo, err := getRepo("")
if err != nil {
return err
}
Expand Down

0 comments on commit 098f349

Please sign in to comment.