Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure branches and labels #4

Open
nicklasfrahm opened this issue Nov 14, 2021 · 0 comments
Open

Configure branches and labels #4

nicklasfrahm opened this issue Nov 14, 2021 · 0 comments
Assignees
Labels
✨ enhancement New feature or request

Comments

@nicklasfrahm
Copy link
Owner

nicklasfrahm commented Nov 14, 2021

The following parameters should be configured for all repositories:

  • Set default branch to main
  • Configure branch protection
  • Set up unified set of labels across all repositories

Attached you may also find a code sample of a previous iteration.

var labels = []Label{
	NewLabel("f44336", "bug", "Something isn't working"),
	NewLabel("e91e63", "dependencies", "Pull requests that updates a dependency file"),
	NewLabel("9e9e9e", "duplicate", "This issue or pull request already exists"),
	NewLabel("3f51b5", "feature", "New feature or request"),
	NewLabel("673ab7", "good first issue", "Good for newcomers"),
	NewLabel("009688", "help wanted", "Extra attention is needed"),
	NewLabel("ffeb3b", "invalid", "This doesn't seem right"),
	NewLabel("9c27b0", "question", "Further information is requested"),
	NewLabel("ffffff", "wontfix", "This will not be worked on"),
	NewLabel("304ffe", "python", "Pull requests that update Python code"),
	NewLabel("00bcd4", "go", "Pull requests that update Go code"),
}

type Label struct {
	Color       string
	Name        string
	Description string
}

func NewLabel(color string, name string, description string) Label {
	return Label{Color: color, Name: name, Description: description}
}

func ConfigureLabels(ctx *pulumi.Context, provider *github.Provider, repo Repository, id pulumi.StringOutput) error {
	for _, label := range labels {
		_, err := github.NewIssueLabel(ctx, fmt.Sprintf("%s-%s", repo.Name, label.Name), &github.IssueLabelArgs{
			Repository:  id,
			Color:       pulumi.String(label.Color),
			Name:        pulumi.String(label.Name),
			Description: pulumi.String(label.Description),
		}, pulumi.Provider(provider))
		if err != nil {
			return err
		}
	}

	return nil
}

func ConfigureBranches(ctx *pulumi.Context, provider *github.Provider, repo Repository) error {
	branch := "main"

	_, err := github.NewBranch(ctx, fmt.Sprintf("%s-%s", repo.Name, branch), &github.BranchArgs{
		Repository: pulumi.String(repo.Name),
		Branch:     pulumi.String(branch),
	}, pulumi.Provider(provider))
	if err != nil {
		return err
	}

	return nil
}
@nicklasfrahm nicklasfrahm added the ✨ enhancement New feature or request label Nov 14, 2021
@nicklasfrahm nicklasfrahm self-assigned this Nov 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant