Files
endoflife-date-release-data/update.rb
Marc Wrobel 62e466a841 Cleanup and fix update.rb (#261)
Cleanup unused code in update.rb: all methods are now handled by custom scripts. This should fix errors encountered in update.yml workflow (such as https://github.com/endoflife-date/release-data/actions/runs/7279373761) since the dependency to psych has been removed.

This also reformat and update the update.yml workflow so that two workflows targeting the same branch cannot run concurrently. This change has been done because in such cases the last one always fail (changes cannot be commited because the previous workflow already update the branch).

Fixes #260.
2023-12-22 23:13:03 +01:00

38 lines
968 B
Ruby

require 'set'
require 'json'
require 'rugged'
def generate_commit_message
begin
products = Set.new
ret = nil
msg = ""
r = Rugged::Repository.new '.'
r.status() do |f, s|
p = Pathname.new(f).dirname
if p.to_s === 'releases'
ret = true
product = File.basename(f, '.json')
products << product
old_version_list = JSON.parse(r.blob_at(r.head.target.oid, f).content).keys.to_set
new_version_list = JSON.parse(File.read(f)).keys.to_set
new_versions = (new_version_list - old_version_list)
msg += "#{product}: #{new_versions.join(', ')}\n"
end
end
commit_title = products.join(', ')
return ret ? "🤖: #{commit_title}\n\n#{msg}": ""
rescue StandardError => e
return "🤖: Automatic Update"
end
end
def github_actions_step_output(msg)
puts "::set-output name=commit_message::#{JSON.dump(msg)}"
end
github_actions_step_output(generate_commit_message)