11package gha
22
33import (
4+ "github.com/alexellis/gha-bump/pkg/ghabump"
45 "github.com/spf13/cobra"
56)
67
@@ -10,15 +11,55 @@ func MakeGHA() *cobra.Command {
1011 Use : "gha" ,
1112 Short : "GitHub Actions utilities" ,
1213 Long : `Utilities for GitHub Actions workflows.` ,
13- Example : ` arkade gha upgrade --help` ,
14+ Example : ` arkade gha bump --help` ,
1415 SilenceUsage : true ,
1516 }
1617
1718 command .RunE = func (cmd * cobra.Command , args []string ) error {
1819 return cmd .Usage ()
1920 }
2021
21- command .AddCommand (MakeUpgrade ())
22+ command .AddCommand (MakeBump ())
23+
24+ return command
25+ }
26+
27+ func MakeBump () * cobra.Command {
28+ var command = & cobra.Command {
29+ Use : "bump" ,
30+ Short : "Upgrade actions in GitHub Actions workflow files to the latest major version" ,
31+ Aliases : []string {"u" },
32+ Long : `Upgrade actions in GitHub Actions workflow files to the latest major version.
33+
34+ Processes all workflow YAML files in .github/workflows/ or a single file.
35+ Only bumps major versions (e.g. actions/checkout@v3 to actions/checkout@v4).
36+ ` ,
37+ Example : ` # Upgrade all workflows in the current directory
38+ arkade gha bump
39+
40+ # Upgrade a single workflow file
41+ arkade gha bump -f .github/workflows/build.yaml
42+
43+ # Dry-run mode, don't write changes
44+ arkade gha bump --write=false` ,
45+ SilenceUsage : true ,
46+ }
47+
48+ command .Flags ().StringP ("file" , "f" , "." , "Path to workflow file or directory" )
49+ command .Flags ().BoolP ("verbose" , "v" , true , "Verbose output" )
50+ command .Flags ().BoolP ("write" , "w" , true , "Write the updated values back to the file" )
51+
52+ command .RunE = func (cmd * cobra.Command , args []string ) error {
53+ target , _ := cmd .Flags ().GetString ("file" )
54+ verbose , _ := cmd .Flags ().GetBool ("verbose" )
55+ write , _ := cmd .Flags ().GetBool ("write" )
56+
57+ return ghabump .Run (ghabump.RunOptions {
58+ Target : target ,
59+ Verbose : verbose ,
60+ Write : write ,
61+ })
62+ }
2263
2364 return command
2465}
0 commit comments