Skip to content

[FEATURE] - ADD GH ENVIRONMENT SECRET CREATION #124

@patrick-hermann-sva

Description

@patrick-hermann-sva
package main

import (
	"context"
	"fmt"
	"log"

	"github.com/google/go-github/v65/github"
)

func main() {
	token := ""
	repo := "stuttgart-things"
	owner := "stuttgart-things"

	if token == "" {
		log.Fatal("Unauthorized: No token present")
	}

	ctx := context.Background()
	client := github.NewClient(nil).WithAuthToken(token)

	opts := &github.EnvironmentListOptions{ListOptions: github.ListOptions{}}
	envResponse, _, err := client.Repositories.ListEnvironments(ctx, owner, repo, opts)
	if err != nil {
		log.Fatal(err)
	}

	// The number of environments here should be equal to expectedPageSize
	fmt.Printf("%d environments returned\n", len(envResponse.Environments))

	// loop through the environments and print the name
	for _, env := range envResponse.Environments {
		fmt.Printf("Environment: %s\n", env.GetName())
	}

}

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions