@@ -125,7 +125,9 @@ def _update_workflow_content(
125125 if self .is_local_repo (repo_name ):
126126 with open (workflow_path , 'w' ) as f :
127127 f .write (workflow_content )
128- return
128+ click .secho (f'Updated workflow in { workflow_path } ' , fg = 'cyan' )
129+ return
130+
129131 # remote
130132 repo = self .client .get_repo (repo_name )
131133 current_content = repo .get_contents (workflow_path )
@@ -135,6 +137,7 @@ def _update_workflow_content(
135137 workflow_content ,
136138 current_content .sha ,
137139 )
140+ click .secho (f'Committed changes to workflow in { repo_name } :{ workflow_path } ' , fg = 'cyan' )
138141 return res
139142
140143
@@ -144,24 +147,28 @@ def _update_workflow_content(
144147 help = 'GitHub token to use, by default will use GITHUB_TOKEN environment variable' )
145148@click .pass_context
146149def cli (ctx , repo : str , github_token : str ):
150+ ctx .ensure_object (dict )
147151 ctx .obj ['gh' ] = GithubActionsTools (github_token )
148152 ctx .obj ['repo' ] = repo
149153
150154
151155@cli .command (help = 'List actions in a workflow' )
152- @click .option ('--dry-run' , default = False , help = 'Do not update, list only' )
156+ @click .option ('--dry-run' , is_flag = True , default = False , help = 'Do not update, list only' )
153157@click .option ('-commit-msg' , default = 'Update github-actions' ,
154158 help = 'Commit msg, only relevant when remote repo' )
155159@click .pass_context
156160def update_actions (ctx , dry_run : bool , commit_msg : str ):
157161 gh , repo = ctx .obj ['gh' ], ctx .obj ['repo' ]
158162 action_versions = gh .get_repo_actions_latest (repo )
159163 for wf in action_versions :
160- click .echo (f'{ wf } :' )
164+ click .secho (f'{ wf } :' , fg = 'blue ' )
161165 for action in action_versions [wf ]:
162- s = f' { action [0 ]} @ { action [1 ]} '
166+ s = f'\t { action [0 ]:30 } { action [1 ]:>5 } '
163167 if action [2 ]:
164- s += f' \t ==> { action [2 ]} '
168+ old_version = action [1 ].split ('.' )
169+ new_version = action [2 ].split ('.' )
170+ color = 'red' if new_version [0 ] != old_version [0 ] else 'cyan'
171+ s += ' ==> ' + click .style (f'{ action [2 ]} ' , fg = color )
165172 click .echo (s )
166173 if dry_run :
167174 return
0 commit comments