Skip to content

Commit f9408ac

Browse files
authored
Merge pull request #21 from github/sync
Add a `sync` subcommand.
2 parents 835cbbd + 7d34469 commit f9408ac

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

cmd/root.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,9 @@ func Execute(ctx context.Context) error {
5858
rootCmd.AddCommand(pushCmd)
5959
pushFlags.Init(pushCmd)
6060

61+
rootCmd.AddCommand(syncCmd)
62+
pullFlags.Init(syncCmd)
63+
pushFlags.Init(syncCmd)
64+
6165
return rootCmd.ExecuteContext(ctx)
6266
}

cmd/sync.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package cmd
2+
3+
import (
4+
"github.com/github/codeql-action-sync/internal/cachedirectory"
5+
"github.com/github/codeql-action-sync/internal/pull"
6+
"github.com/github/codeql-action-sync/internal/push"
7+
"github.com/spf13/cobra"
8+
)
9+
10+
var syncCmd = &cobra.Command{
11+
Use: "sync",
12+
Short: "Sync the CodeQL Action from GitHub to a GitHub Enterprise Server installation.",
13+
RunE: func(cmd *cobra.Command, args []string) error {
14+
cacheDirectory := cachedirectory.NewCacheDirectory(rootFlags.cacheDir)
15+
err := pull.Pull(cmd.Context(), cacheDirectory)
16+
if err != nil {
17+
return err
18+
}
19+
err = push.Push(cmd.Context(), cacheDirectory, pushFlags.destinationURL, pushFlags.destinationToken, pushFlags.destinationRepository)
20+
if err != nil {
21+
return err
22+
}
23+
return nil
24+
},
25+
}

0 commit comments

Comments
 (0)