Skip to content

Commit

Permalink
Simplify changelog.rb
Browse files Browse the repository at this point in the history
Only .changes files are passed to this script by the get-changed-files
action.
  • Loading branch information
agraul committed Oct 21, 2021
1 parent 40949fc commit 4f252ea
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions .github/scripts/changelog.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#! /usr/bin/ruby
require 'json'

# if true we exit with 0, so the test is sucessefull. otherwise the test fail.
def check_changelog?(pr_body, files)
return true if pr_body.match(/\[x\]\s+No\s+changelog\s+needed/i)

puts 'Looking for a .changes file...'
files.any? { |f| f.include? '.changes' }
def not_needed?(pr_body)
return pr_body.match(/\[x\]\s+No\s+changelog\s+needed/i)
end

github_event = JSON.parse(File.read(ENV['GITHUB_EVENT_PATH']))
files = ARGV[0].split(' ')
pr_body = github_event['pull_request']['body']
changes_files = ARGV[0].split(' ')
puts "-" * 20, "PR Description: #{github_event['pull_request']['body']}"
puts "-" * 20, "Files modified: #{files}"
check_changelog?(github_event['pull_request']['body'], files) ? exit(0) : exit(1)
puts "-" * 20, "Added or modified .changes files: #{changes_files}"

exit(0) unless changes_files.empty?

not_needed?(pr_body) ? exit(0) : exit(1)

0 comments on commit 4f252ea

Please sign in to comment.