From bc42a621f5da6adc6b0c52a989ad90205eed3e1f Mon Sep 17 00:00:00 2001 From: Igor Cherkaev Date: Wed, 7 Sep 2022 15:31:40 -0500 Subject: [PATCH] 2.1.2: fix merge_pull action Signed-off-by: Igor Cherkaev --- actions/merge_pull.py | 23 ++++++++++++++++++++--- pack.yaml | 2 +- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/actions/merge_pull.py b/actions/merge_pull.py index 81135d3..d7f7204 100644 --- a/actions/merge_pull.py +++ b/actions/merge_pull.py @@ -12,12 +12,29 @@ def run(self, user, repo, pull_id): repo = user.get_repo(repo) pull = repo.get_pull(pull_id) - if pull.mergeable: - return (False, 'Pull Request is not mergeable') if pull.merged: - return (False, 'Pull Request is already merged') + return False, 'Pull Request is already merged' + if not pull.mergeable: + return False, 'Pull Request is not mergeable' status = pull.merge() result = {'merged': status.merged, 'message': status.message} return result + + +if __name__ == '__main__': + import os + + GITHUB_TOKEN = os.environ.get('GITHUB_TOKEN') + GITHUB_ORG = os.environ.get('GITHUB_ORG') + GITHUB_REPO = os.environ.get('GITHUB_REPO') + GITHUB_BRANCH = os.environ.get('GITHUB_BRANCH') + + PULL_ID = 13 + act = MergePullAction(config={'token': GITHUB_TOKEN, 'github_type': 'online'}) + res = act.run(user=GITHUB_ORG, repo=GITHUB_REPO, pull_id=PULL_ID) + import pprint + + pp = pprint.PrettyPrinter(indent=4) + pp.pprint(res) diff --git a/pack.yaml b/pack.yaml index f730436..6138ecd 100644 --- a/pack.yaml +++ b/pack.yaml @@ -8,7 +8,7 @@ keywords: - git - scm - serverless -version: 2.1.0 +version: 2.1.2 python_versions: - "3" author : StackStorm, Inc.