-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Only .changes files are passed to this script by the get-changed-files action.
- Loading branch information
Showing
1 changed file
with
9 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |