Skip to content

Commit

Permalink
fix: assigning issues permission error (#187)
Browse files Browse the repository at this point in the history
Assign issues to charm tech members and mention interface maintainers in the issue body.
  • Loading branch information
IronCore864 authored Nov 6, 2024
1 parent 58d49b4 commit a2ceb1b
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions run_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,18 +357,24 @@ def create_issue(
):
gh = Github(os.getenv("GITHUB_TOKEN"))
repo = gh.get_repo("canonical/charm-relation-interfaces")
issue_assignees = ["IronCore864", "tonyandrewmeyer"]
workflow_url = ""
github_run_id = os.getenv("GITHUB_RUN_ID")
if github_run_id:
workflow_url = f"https://github.com/canonical/charm-relation-interfaces/actions/runs/{github_run_id}"
result = flatten_test_result(result_per_role)
title = f"Interface test for {interface} {version} failed."
mention_team_members = ", ".join(
["@" + member for member in get_team_members_from_team_slug(maintainer)]
)
body = f"""\
Tests for interface {interface} {version} failed.
{result}
See the workflow {workflow_url} for more detail.
{mention_team_members}
"""

issue = None
Expand All @@ -378,18 +384,12 @@ def create_issue(
issue = existing_issue
break

# Issues in public repositories can have up to 10 people assigned.
# https://github.com/canonical/charm-relation-interfaces/actions/runs/11318866281
team_members = get_team_members_from_team_slug(maintainer)[:10]
if issue:
issue.create_comment(body)
print(f"GitHub issue updated: {issue.html_url}")
if team_members:
issue.edit(assignees=team_members)
print(f"GitHub issue assigned to {team_members}")
else:
issue = repo.create_issue(
title=title, body=body, assignees=team_members, labels=labels
title=title, body=body, assignees=issue_assignees, labels=labels
)
print(f"GitHub issue created: {issue.html_url}")

Expand Down

0 comments on commit a2ceb1b

Please sign in to comment.