|
1 | 1 | package cmd
|
2 | 2 |
|
3 | 3 | import (
|
| 4 | + "os" |
| 5 | + |
4 | 6 | "github.com/github/codeql-action-sync/internal/cachedirectory"
|
| 7 | + "github.com/github/codeql-action-sync/internal/environment" |
5 | 8 | "github.com/github/codeql-action-sync/internal/push"
|
6 | 9 | "github.com/github/codeql-action-sync/internal/version"
|
7 | 10 | "github.com/spf13/cobra"
|
@@ -31,8 +34,13 @@ var pushFlags = pushFlagFields{}
|
31 | 34 | func (f *pushFlagFields) Init(cmd *cobra.Command) {
|
32 | 35 | cmd.Flags().StringVar(&f.destinationURL, "destination-url", "", "The URL of the GitHub Enterprise instance to push to.")
|
33 | 36 | cmd.MarkFlagRequired("destination-url")
|
34 |
| - cmd.Flags().StringVar(&f.destinationToken, "destination-token", "", "A token to access the API on the GitHub Enterprise instance.") |
35 |
| - cmd.MarkFlagRequired("destination-token") |
| 37 | + cmd.Flags().StringVar(&f.destinationToken, "destination-token", "", "A token to access the API on the GitHub Enterprise instance (can also be provided by setting the "+environment.DestinationToken+" environment variable).") |
| 38 | + if f.destinationToken == "" { |
| 39 | + f.destinationToken = os.Getenv(environment.DestinationToken) |
| 40 | + if f.destinationToken == "" { |
| 41 | + cmd.MarkFlagRequired("destination-token") |
| 42 | + } |
| 43 | + } |
36 | 44 | cmd.Flags().StringVar(&f.destinationRepository, "destination-repository", "github/codeql-action", "The name of the repository to create on GitHub Enterprise.")
|
37 | 45 | cmd.Flags().StringVar(&f.actionsAdminUser, "actions-admin-user", "actions-admin", "The name of the Actions admin user.")
|
38 | 46 | cmd.Flags().BoolVar(&f.force, "force", false, "Replace the existing repository even if it was not created by the sync tool.")
|
|
0 commit comments