-
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
13 additions
and
10 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,19 @@ | ||
#! /usr/bin/ruby | ||
# Check if a .changes file is added/modified in a pull request *or* the "No | ||
# changelog needed" box in the pull request description is ticked. If neither of | ||
# these are true, exit 1 to fail the check. | ||
# | ||
# List of added/modified in the pull request is stored in ARGV | ||
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) | ||
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(' ') | ||
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) | ||
pr_body = github_event['pull_request']['body'] | ||
puts '-' * 20, "PR Description: #{github_event['pull_request']['body']}" | ||
puts '-' * 20, "Added or modified .changes files: #{ARGV}" | ||
|
||
exit(0) unless ARGV.empty? | ||
not_needed?(pr_body) ? exit(0) : exit(1) |