From 4c463c36efa37f9e5ab5acaec52e153abc090dcb Mon Sep 17 00:00:00 2001 From: 5an7y Date: Mon, 14 Jul 2025 10:22:08 -0700 Subject: Made the query more efficient --- .github/workflows/tag-codeowner-on-issue.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/tag-codeowner-on-issue.yml b/.github/workflows/tag-codeowner-on-issue.yml index 088500d7..eb9c0523 100644 --- a/.github/workflows/tag-codeowner-on-issue.yml +++ b/.github/workflows/tag-codeowner-on-issue.yml @@ -46,7 +46,7 @@ jobs: with open(".github/CODEOWNERS", "r") as f: lines = f.readlines() - codeowners = {} + codeowner = None sample_section = False for line in lines: line = line.strip() @@ -57,15 +57,16 @@ jobs: if line.startswith("#") or not line: continue path, owner = line.split() - codeowners[path] = owner + if path == selected_path: + codeowner = owner + break - owner = codeowners.get(selected_path) - if not owner: + if codeowner is None: print(f"No codeowner found for path: {selected_path}") exit(0) # Post a comment tagging the owner - comment = f"{owner} can you please take a look at this issue related to `{selected_path}`?" + comment = f"{codeowner} can you please take a look at this issue related to `{selected_path}`?" issue_number = os.environ['GITHUB_REF'].split('/')[-1] repo = os.environ['GITHUB_REPOSITORY'] token = os.environ['GITHUB_TOKEN'] -- cgit v1.3.1