From 9727594d899b4aef977731f87731c5914634a71e Mon Sep 17 00:00:00 2001 From: Jon Date: Sat, 12 Jul 2025 19:12:57 +0930 Subject: [PATCH] feat(annotations): when no problem found, remove comment and set to approve PR ref: #6 #5 --- includes/usr/bin/annotations.py | 11 ++++++++++- playbooks/problem_matcher.yaml | 4 ++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/includes/usr/bin/annotations.py b/includes/usr/bin/annotations.py index 733983b..4ffef7b 100755 --- a/includes/usr/bin/annotations.py +++ b/includes/usr/bin/annotations.py @@ -6,7 +6,7 @@ import json # import requests import os - +# API Docs: https://docs.github.com/en/rest/pulls/reviews?apiVersion=2022-11-28#create-a-review-for-a-pull-request def default_matcher( entry, tool_name = '' ) -> dict: @@ -277,6 +277,15 @@ for msg_type, value in review_body.items(): ) +if len(api_body['comments']) == 0: + + api_body.update({ + 'event': 'APPROVE' + }) + del api_body['body'] + + + data = { "pull_request": pull_request, "api_body": api_body diff --git a/playbooks/problem_matcher.yaml b/playbooks/problem_matcher.yaml index 443d9d8..656ff71 100644 --- a/playbooks/problem_matcher.yaml +++ b/playbooks/problem_matcher.yaml @@ -18,14 +18,14 @@ ansible.builtin.set_fact: git_api_url: "{{ payload.repository.url }}" when: > - git_api_url == "" + git_api_url == "" - name: Set var gitea_replace_url if empty ansible.builtin.set_fact: gitea_replace_url: "{{ payload.repository.url }}" when: > - gitea_replace_url == "" + gitea_replace_url == "" - name: Set required Facts