Sha256: a796d981172cb54b392c9fa7b0db83f71269be5ef081acd66fc68270878099b4

Contents?: true

Size: 987 Bytes

Versions: 3

Compression:

Stored size: 987 Bytes

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

require 'optparse'
require 'colorize'
require 'action'

OptionParser.new do |parser|
  parser.version = File.read("#{__dir__}/../VERSION")
  parser.banner += ' workflows ...'
  parser.on('-n', '--newer', 'deal only with actions that have an update') do
    @newer = true
  end
  parser.on('-w', '--write', 'write updates back to workflow files') do
    @write = true
  end
end.parse!

ARGV.each do |path|
  puts "#{'==>'.blue} #{path}".bold
  yaml = File.read(path)
  actions = Action.array_from_yaml(yaml)
  actions.each do |current_action|
    new_action = current_action.clone
    new_action.ref = current_action.latest_tag

    next if current_action == new_action && @newer

    puts "#{current_action.print_without_ref.cyan.bold} : #{current_action.ref.red.bold} ==> #{new_action.ref.green.bold}"

    next unless @write

    yaml.gsub!(/#{current_action}/, new_action.to_s)
    File.open(path, 'w') { |f| f.puts yaml }
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
actions-updater-0.1.10 bin/actions-updater
actions-updater-0.1.9 bin/actions-updater
actions-updater-0.1.8 bin/actions-updater