@@ -24,12 +24,13 @@ import (
2424)
2525
2626type migrateOptions struct {
27- token string
28- orgID string
29- yes bool
30- overwrite bool
31- dir string
32- stdout io.Writer
27+ token string
28+ orgID string
29+ yes bool
30+ overwrite bool
31+ dir string
32+ stdout io.Writer
33+ branchName string
3334}
3435
3536func NewCmdMigrate () * cobra.Command {
@@ -62,7 +63,7 @@ func NewCmdMigrate() *cobra.Command {
6263}
6364
6465func newCmdSecretsAndVars (parentOpts * migrateOptions ) * cobra.Command {
65- return & cobra.Command {
66+ cmd := & cobra.Command {
6667 Use : "secrets-and-vars" ,
6768 Short : "Import GitHub Actions secrets and variables into Depot CI" ,
6869 Long : "Creates a one-shot GitHub Actions workflow that reads secrets and variables from the source repo and imports them into Depot CI via the depot CLI." ,
@@ -73,6 +74,10 @@ func newCmdSecretsAndVars(parentOpts *migrateOptions) *cobra.Command {
7374 return secretsAndVars (cmd .Context (), opts )
7475 },
7576 }
77+
78+ cmd .Flags ().StringVar (& parentOpts .branchName , "branch" , "" , "Override the branch name used for the migration workflow" )
79+
80+ return cmd
7681}
7782
7883func secretsAndVars (ctx context.Context , opts migrateOptions ) error {
@@ -128,10 +133,14 @@ func secretsAndVars(ctx context.Context, opts migrateOptions) error {
128133
129134 if preview {
130135 dryResp , err := client .ImportSecretsAndVars (ctx , api .WithAuthenticationAndOrg (
131- connect .NewRequest (& civ1.ImportSecretsAndVarsRequest {Repo : repo , DryRun : true }),
136+ connect .NewRequest (& civ1.ImportSecretsAndVarsRequest {Repo : repo , DryRun : true , BranchName : opts . branchName }),
132137 token , orgID ,
133138 ))
134139 if err != nil {
140+ var connectErr * connect.Error
141+ if errors .As (err , & connectErr ) {
142+ return fmt .Errorf ("%s" , connectErr .Message ())
143+ }
135144 return fmt .Errorf ("failed to preview: %w" , err )
136145 }
137146
@@ -170,10 +179,14 @@ func secretsAndVars(ctx context.Context, opts migrateOptions) error {
170179 }
171180
172181 resp , err := client .ImportSecretsAndVars (ctx , api .WithAuthenticationAndOrg (
173- connect .NewRequest (& civ1.ImportSecretsAndVarsRequest {Repo : repo }),
182+ connect .NewRequest (& civ1.ImportSecretsAndVarsRequest {Repo : repo , BranchName : opts . branchName }),
174183 token , orgID ,
175184 ))
176185 if err != nil {
186+ var connectErr * connect.Error
187+ if errors .As (err , & connectErr ) {
188+ return fmt .Errorf ("%s" , connectErr .Message ())
189+ }
177190 return fmt .Errorf ("failed to import secrets and variables: %w" , err )
178191 }
179192
0 commit comments