update workflow
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
997ce8945f
commit
38bc8b8841
@ -38,15 +38,16 @@ var (
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
PullRequestTitle string `json:"pull_request_title" yaml:"pull_request_title"`
|
||||
PullRequestBody string `json:"pull_request_body" yaml:"pull_request_body"`
|
||||
PullRequestTitle string `json:"pull_request_title" yaml:"pull_request_title"`
|
||||
PullRequestBody string `json:"pull_request_body" yaml:"pull_request_body"`
|
||||
Branches []string `json:"branches" yaml:"branches"`
|
||||
}
|
||||
|
||||
var (
|
||||
configFiles = []string{
|
||||
"dependabot.yml",
|
||||
"pkgdash.yml",
|
||||
"pkgdash.yaml",
|
||||
"pkgdashcli.yml",
|
||||
"pkgdashcli.yaml",
|
||||
}
|
||||
configDirs = []string{
|
||||
".gitea",
|
||||
@ -158,10 +159,11 @@ func main() {
|
||||
logger.Fatalf(ctx, "failed to get repo management")
|
||||
}
|
||||
|
||||
branch := os.Getenv("GITHUB_REF_NAME")
|
||||
switch repoMgmt {
|
||||
case "gitea":
|
||||
err = giteaPullRequest(ctx, cfg, branch, mvs)
|
||||
for _, branch := range cfg.Branches {
|
||||
err = giteaPullRequest(ctx, cfg, branch, mvs)
|
||||
}
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
@ -224,9 +226,25 @@ func giteaPullRequest(ctx context.Context, cfg *Config, branch string, mods map[
|
||||
logger.Fatalf(ctx, "failed to fetch repo: %v", err)
|
||||
}
|
||||
|
||||
headRef, err := repo.Head()
|
||||
var headRef *plumbing.Reference
|
||||
refIter, err := repo.Branches()
|
||||
if err != nil {
|
||||
logger.Fatalf(ctx, "failed to get repo head: %v", err)
|
||||
logger.Fatalf(ctx, "failed to get branches: %v", err)
|
||||
}
|
||||
for {
|
||||
ref, err := refIter.Next()
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
if ref.Name().String() == branch {
|
||||
headRef = ref
|
||||
break
|
||||
}
|
||||
}
|
||||
refIter.Close()
|
||||
|
||||
if headRef == nil {
|
||||
logger.Fatalf(ctx, "failed to get repo branch head")
|
||||
}
|
||||
|
||||
logger.Infof(ctx, "repo head %s", headRef)
|
||||
|
Loading…
Reference in New Issue
Block a user