diff --git a/.github/gh-bot.yml b/.github/gh-bot.yml index bb5b3e4..79a5881 100644 --- a/.github/gh-bot.yml +++ b/.github/gh-bot.yml @@ -9,9 +9,7 @@ bot: email: sealos-ci-robot@sealos.io username: sealos-ci-robot repo: - org: true - name: labring-actions/sealos - fork: cuisongliu/sealos + org: false release: retry: 15s diff --git a/cmd/checks.go b/cmd/checks.go index 73f75ee..cb69d99 100644 --- a/cmd/checks.go +++ b/cmd/checks.go @@ -25,13 +25,7 @@ import ( ) func preCheck() error { - var err error - types.GlobalsGithubVar, err = types.GetGHEnvToVar() - if err != nil { - return err - } - logger.Debug("github env to var: %v", types.GlobalsGithubVar) - if err = checkGithubEnv(); err != nil { + if err := checkGithubEnv(); err != nil { return err } return nil @@ -55,6 +49,12 @@ func checkGithubEnv() error { func checkToken() { var err error + types.GlobalsGithubVar, err = types.GetGHEnvToVar() + if err != nil { + logger.Error(err) + os.Exit(1) + } + logger.Debug("github env to var: %v", types.GlobalsGithubVar) types.GlobalsBotConfig, err = types.LoadConfig(cfgFile) if err != nil { logger.Error(err) diff --git a/pkg/types/config.go b/pkg/types/config.go index f84e38e..905d03c 100644 --- a/pkg/types/config.go +++ b/pkg/types/config.go @@ -121,11 +121,17 @@ func (r *Config) GetOrgCommand() string { // GetRepoName returns the name for the repo func (r *Config) GetRepoName() string { + if r.Repo.Name == "" { + r.Repo.Name = fmt.Sprintf("%s/%s", r.Bot.Username, GlobalsGithubVar.RepoName) + } return r.Repo.Name } // GetForkName returns the fork for the repo func (r *Config) GetForkName() string { + if r.Repo.Fork == "" { + r.Repo.Fork = GlobalsGithubVar.SafeRepo + } return r.Repo.Fork } diff --git a/pkg/types/gh_env.go b/pkg/types/gh_env.go index f41f866..061dbaf 100644 --- a/pkg/types/gh_env.go +++ b/pkg/types/gh_env.go @@ -28,6 +28,7 @@ import ( type GithubVar struct { RunnerID string SafeRepo string + RepoName string IssueOrPRNumber int64 CommentBody string SenderOrCommentUser string @@ -61,6 +62,7 @@ func GetGHEnvToVar() (*GithubVar, error) { } gVar.IssueOrPRNumber = id gVar.SafeRepo, _, _ = unstructured.NestedString(mData, "repository", "full_name") + gVar.RepoName, _, _ = unstructured.NestedString(mData, "repository", "name") gVar.CommentBody, _, _ = unstructured.NestedString(mData, "comment", "body") user, ok, _ := unstructured.NestedString(mData, "comment", "user", "login")