()
| 23 | ) |
| 24 | |
| 25 | func main() { |
| 26 | flag.Parse() |
| 27 | token := os.Getenv("GITHUB_AUTH_TOKEN") |
| 28 | if token == "" { |
| 29 | log.Fatal("Unauthorized: No token present") |
| 30 | } |
| 31 | if *name == "" { |
| 32 | log.Fatal("No name: repo name must be given") |
| 33 | } |
| 34 | if *owner == "" { |
| 35 | log.Fatal("No owner: owner of repo must be given") |
| 36 | } |
| 37 | ctx := context.Background() |
| 38 | client, err := github.NewClient(github.WithAuthToken(token)) |
| 39 | if err != nil { |
| 40 | log.Fatal(err) |
| 41 | } |
| 42 | |
| 43 | actionsPermissionsRepository, _, err := client.Repositories.GetActionsPermissions(ctx, *owner, *name) |
| 44 | if err != nil { |
| 45 | log.Fatal(err) |
| 46 | } |
| 47 | |
| 48 | fmt.Printf("Current ActionsPermissions %v\n", actionsPermissionsRepository) |
| 49 | |
| 50 | actionsPermissionsRepository = &github.ActionsPermissionsRepository{Enabled: github.Ptr(true), AllowedActions: github.Ptr("selected")} |
| 51 | _, _, err = client.Repositories.UpdateActionsPermissions(ctx, *owner, *name, *actionsPermissionsRepository) |
| 52 | if err != nil { |
| 53 | log.Fatal(err) |
| 54 | } |
| 55 | |
| 56 | fmt.Printf("Current ActionsPermissions %v\n", actionsPermissionsRepository) |
| 57 | |
| 58 | actionsAllowed, _, err := client.Repositories.GetActionsAllowed(ctx, *owner, *name) |
| 59 | if err != nil { |
| 60 | log.Fatal(err) |
| 61 | } |
| 62 | |
| 63 | fmt.Printf("Current ActionsAllowed %v\n", actionsAllowed) |
| 64 | |
| 65 | actionsAllowed = &github.ActionsAllowed{GithubOwnedAllowed: github.Ptr(true), VerifiedAllowed: github.Ptr(false), PatternsAllowed: []string{"a/b"}} |
| 66 | _, _, err = client.Repositories.EditActionsAllowed(ctx, *owner, *name, *actionsAllowed) |
| 67 | if err != nil { |
| 68 | log.Fatal(err) |
| 69 | } |
| 70 | |
| 71 | fmt.Printf("Current ActionsAllowed %v\n", actionsAllowed) |
| 72 | |
| 73 | actionsPermissionsRepository = &github.ActionsPermissionsRepository{Enabled: github.Ptr(true), AllowedActions: github.Ptr("all")} |
| 74 | _, _, err = client.Repositories.UpdateActionsPermissions(ctx, *owner, *name, *actionsPermissionsRepository) |
| 75 | if err != nil { |
| 76 | log.Fatal(err) |
| 77 | } |
| 78 | |
| 79 | fmt.Printf("Current ActionsPermissions %v\n", actionsPermissionsRepository) |
| 80 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…