From 3c03c32553a2eb0e5fea8e953a87c0bf5d57eb20 Mon Sep 17 00:00:00 2001 From: Simon Urli Date: Thu, 2 Feb 2017 16:17:45 +0100 Subject: [PATCH] chore: only publish revapi report if the PR is edited or opened. (#1161) --- chore/revapy.py | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/chore/revapy.py b/chore/revapy.py index cd195c4493a..29756df70a0 100644 --- a/chore/revapy.py +++ b/chore/revapy.py @@ -7,6 +7,7 @@ from github import * revapi_file = "./target/revapi_report.md" +accepted_actions = ["opened", "synchronize"] args = sys.argv @@ -57,13 +58,18 @@ def usage(): payloadJSON = json.loads(payload_string) repo_name = payloadJSON['repository']['full_name'] pr_id = payloadJSON['pull_request']['number'] - -try: - repo = gh.get_repo(repo_name,True) - - pr = repo.get_pull(pr_id) - pr.create_issue_comment(file_content) -except GithubException as e: - print "Error while creating the PR comment." - print e - exit(1) +action = payloadJSON['action'] + +if (action in accepted_actions): + try: + repo = gh.get_repo(repo_name,True) + + pr = repo.get_pull(pr_id) + pr.create_issue_comment(file_content) + except GithubException as e: + print "Error while creating the PR comment." + print e + exit(1) +else: + print "Call action: "+action + exit(0)