pr: add reviewers to PR workflow
This commit is contained in:
@@ -22,6 +22,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
"slices"
|
||||
"strings"
|
||||
@@ -32,6 +33,7 @@ type AutogitConfig struct {
|
||||
Organization string
|
||||
GitProjectName string // Organization/GitProjectName.git is PrjGit
|
||||
Branch string // branch name of PkgGit that aligns with PrjGit submodules
|
||||
Reviewers []string // only used by `pr` workflow
|
||||
}
|
||||
|
||||
func ReadWorkflowConfigs(reader io.Reader) ([]*AutogitConfig, error) {
|
||||
@@ -47,7 +49,11 @@ func ReadWorkflowConfigs(reader io.Reader) ([]*AutogitConfig, error) {
|
||||
|
||||
availableWorkflows := []string{"pr", "direct", "test"}
|
||||
for _, workflow := range config {
|
||||
pr := false
|
||||
for _, w := range workflow.Workflows {
|
||||
if w == "pr" {
|
||||
pr = true
|
||||
}
|
||||
if !slices.Contains(availableWorkflows, w) {
|
||||
return nil, fmt.Errorf(
|
||||
"Invalid Workflow '%s'. Only available workflows are: %s",
|
||||
@@ -58,6 +64,12 @@ func ReadWorkflowConfigs(reader io.Reader) ([]*AutogitConfig, error) {
|
||||
if len(workflow.GitProjectName) == 0 {
|
||||
workflow.GitProjectName = DefaultGitPrj
|
||||
}
|
||||
if !pr && len(workflow.Reviewers) > 0 {
|
||||
log.Println(" Warning: non-PR-only workflows contains Reviewers. These are ignored in Org:", workflow.Organization)
|
||||
}
|
||||
if pr && !slices.Contains(workflow.Reviewers, Bot_BuildReview) {
|
||||
workflow.Reviewers = append(workflow.Reviewers, Bot_BuildReview)
|
||||
}
|
||||
}
|
||||
|
||||
return config, nil
|
||||
|
Reference in New Issue
Block a user