Skip to content

Commit cf7bdeb

Browse files
committed
Add a hidden push option for specifying the destination Git URL.
1 parent 06cf2d3 commit cf7bdeb

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

cmd/push.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ var pushCmd = &cobra.Command{
1616
RunE: func(cmd *cobra.Command, args []string) error {
1717
version.LogVersion()
1818
cacheDirectory := cachedirectory.NewCacheDirectory(rootFlags.cacheDir)
19-
return push.Push(cmd.Context(), cacheDirectory, pushFlags.destinationURL, pushFlags.destinationToken, pushFlags.destinationRepository, pushFlags.actionsAdminUser, pushFlags.force, pushFlags.pushSSH)
19+
return push.Push(cmd.Context(), cacheDirectory, pushFlags.destinationURL, pushFlags.destinationToken, pushFlags.destinationRepository, pushFlags.actionsAdminUser, pushFlags.force, pushFlags.pushSSH, pushFlags.gitURL)
2020
},
2121
}
2222

@@ -27,6 +27,7 @@ type pushFlagFields struct {
2727
actionsAdminUser string
2828
force bool
2929
pushSSH bool
30+
gitURL string
3031
}
3132

3233
var pushFlags = pushFlagFields{}
@@ -45,4 +46,6 @@ func (f *pushFlagFields) Init(cmd *cobra.Command) {
4546
cmd.Flags().StringVar(&f.actionsAdminUser, "actions-admin-user", "actions-admin", "The name of the Actions admin user.")
4647
cmd.Flags().BoolVar(&f.force, "force", false, "Replace the existing repository even if it was not created by the sync tool.")
4748
cmd.Flags().BoolVar(&f.pushSSH, "push-ssh", false, "Push Git contents over SSH rather than HTTPS. To use this option you must have SSH access to your GitHub Enterprise instance configured.")
49+
cmd.Flags().StringVar(&f.gitURL, "git-url", "", "Use a custom Git URL for pushing the Action repository contents to.")
50+
cmd.Flags().MarkHidden("git-url")
4851
}

cmd/sync.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ var syncCmd = &cobra.Command{
1818
if err != nil {
1919
return err
2020
}
21-
err = push.Push(cmd.Context(), cacheDirectory, pushFlags.destinationURL, pushFlags.destinationToken, pushFlags.destinationRepository, pushFlags.actionsAdminUser, pushFlags.force, pushFlags.pushSSH)
21+
err = push.Push(cmd.Context(), cacheDirectory, pushFlags.destinationURL, pushFlags.destinationToken, pushFlags.destinationRepository, pushFlags.actionsAdminUser, pushFlags.force, pushFlags.pushSSH, pushFlags.gitURL)
2222
if err != nil {
2323
return err
2424
}

internal/push/push.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ type pushService struct {
5353
aegis bool
5454
force bool
5555
pushSSH bool
56+
gitURL string
5657
}
5758

5859
func (pushService *pushService) createRepository() (*github.Repository, error) {
@@ -163,9 +164,12 @@ func (pushService *pushService) createRepository() (*github.Repository, error) {
163164
}
164165

165166
func (pushService *pushService) pushGit(repository *github.Repository, initialPush bool) error {
166-
remoteURL := repository.GetCloneURL()
167-
if pushService.pushSSH {
168-
remoteURL = repository.GetSSHURL()
167+
remoteURL := pushService.gitURL
168+
if remoteURL == "" {
169+
remoteURL = repository.GetCloneURL()
170+
if pushService.pushSSH {
171+
remoteURL = repository.GetSSHURL()
172+
}
169173
}
170174
if initialPush {
171175
log.Debugf("Pushing Git releases to %s...", remoteURL)
@@ -366,7 +370,7 @@ func (pushService *pushService) pushReleases() error {
366370
return nil
367371
}
368372

369-
func Push(ctx context.Context, cacheDirectory cachedirectory.CacheDirectory, destinationURL string, destinationToken string, destinationRepository string, actionsAdminUser string, force bool, pushSSH bool) error {
373+
func Push(ctx context.Context, cacheDirectory cachedirectory.CacheDirectory, destinationURL string, destinationToken string, destinationRepository string, actionsAdminUser string, force bool, pushSSH bool, gitURL string) error {
370374
err := cacheDirectory.CheckOrCreateVersionFile(false, version.Version())
371375
if err != nil {
372376
return err
@@ -424,6 +428,7 @@ func Push(ctx context.Context, cacheDirectory cachedirectory.CacheDirectory, des
424428
aegis: aegis,
425429
force: force,
426430
pushSSH: pushSSH,
431+
gitURL: gitURL,
427432
}
428433

429434
repository, err := pushService.createRepository()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy