Closes #3
This commit is contained in:
3
.github/workflows/update.yml
vendored
3
.github/workflows/update.yml
vendored
@@ -42,8 +42,9 @@ jobs:
|
|||||||
git config --global init.defaultBranch main
|
git config --global init.defaultBranch main
|
||||||
git config --global extensions.partialClone true
|
git config --global extensions.partialClone true
|
||||||
bundle exec ruby update.rb ./website ~/.cache releases
|
bundle exec ruby update.rb ./website ~/.cache releases
|
||||||
|
id: update_releases
|
||||||
- uses: stefanzweifel/git-auto-commit-action@v4
|
- uses: stefanzweifel/git-auto-commit-action@v4
|
||||||
name: Commit and update new releases
|
name: Commit and update new releases
|
||||||
with:
|
with:
|
||||||
commit_message: Update Releases
|
commit_message: ${{ fromJSON(steps.update_releases.outputs.commit_message)}}
|
||||||
commit_author: 'github-actions[bot] <github-actions[bot]@users.noreply.github.com>'
|
commit_author: 'github-actions[bot] <github-actions[bot]@users.noreply.github.com>'
|
||||||
|
|||||||
28
update.rb
28
update.rb
@@ -1,4 +1,5 @@
|
|||||||
require 'yaml'
|
require 'yaml'
|
||||||
|
require 'set'
|
||||||
require 'date'
|
require 'date'
|
||||||
require 'json'
|
require 'json'
|
||||||
require 'rugged'
|
require 'rugged'
|
||||||
@@ -68,6 +69,26 @@ def get_output_file(ecosystem, product)
|
|||||||
"#{OUTPUT_DIR}/#{ecosystem}/#{product}.json"
|
"#{OUTPUT_DIR}/#{ecosystem}/#{product}.json"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def generate_commit_message
|
||||||
|
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/git'
|
||||||
|
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(', ')}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
ret ? "Updates: #{products.join(', ')}\n\n#{msg}": false
|
||||||
|
end
|
||||||
|
|
||||||
Dir.glob("#{WEBSITE_DIR}/products/*.md").each do |product_file|
|
Dir.glob("#{WEBSITE_DIR}/products/*.md").each do |product_file|
|
||||||
data = YAML.safe_load_file product_file, permitted_classes: [Date]
|
data = YAML.safe_load_file product_file, permitted_classes: [Date]
|
||||||
next unless data['auto']
|
next unless data['auto']
|
||||||
@@ -81,3 +102,10 @@ Dir.glob("#{WEBSITE_DIR}/products/*.md").each do |product_file|
|
|||||||
update_git_releases(get_cache_dir('git', product), get_output_file('git', product), data['auto'])
|
update_git_releases(get_cache_dir('git', product), get_output_file('git', product), data['auto'])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def github_actions_step_output(msg)
|
||||||
|
puts "::set-output name=commit_message::#{JSON.dump(msg)}"
|
||||||
|
end
|
||||||
|
|
||||||
|
msg = generate_commit_message
|
||||||
|
github_actions_step_output(msg) if msg
|
||||||
|
|||||||
Reference in New Issue
Block a user