Skip to content

Commit 9f17fb0

Browse files
authored
Merge pull request #27 from alyssacgoins/issue-triage-3
Issue triage 3
2 parents bff8c01 + bd3d8ab commit 9f17fb0

2 files changed

Lines changed: 59 additions & 0 deletions

File tree

.github/scripts/issue-triage.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env python3
2+
import os
3+
import sys
4+
5+
import yaml
6+
from github import Auth, Github
7+
8+
9+
def get_owners(repo, path="OWNERS"):
10+
"""Fetch and parse a Kubernetes-style OWNERS file from the repository."""
11+
contents = repo.get_contents(path)
12+
owners = yaml.safe_load(contents.decoded_content)
13+
return {
14+
"approvers": owners.get("approvers", []),
15+
"reviewers": owners.get("reviewers", []),
16+
}
17+
18+
19+
def main() -> int:
20+
token = os.getenv("GITHUB_TOKEN")
21+
issue_num = os.getenv("GH_ISSUE")
22+
repo_name = os.getenv("GITHUB_REPOSITORY")
23+
24+
g = Github(auth=Auth.Token(token))
25+
repo = g.get_repo(repo_name)
26+
27+
issue_number = int(issue_num)
28+
issue = repo.get_issue(issue_number)
29+
30+
owners = get_owners(repo)
31+
print(f"Approvers: {owners['approvers']}")
32+
print(f"Reviewers: {owners['reviewers']}")
33+
34+
return 0
35+
36+
37+
if __name__ == "__main__":
38+
sys.exit(main())

.github/workflows/issue-triage.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,27 @@ jobs:
1111
steps:
1212
- name: Welcome message
1313
run: gh issue comment ${{ github.event.issue.number }} --body "Thanks for opening this issue! A maintainer will triage it shortly."
14+
env:
15+
GH_ISSUE: ${{ github.event.issue.number }}
16+
17+
- name: Checkout code
18+
uses: actions/checkout@v6
19+
20+
- name: Set up Python
21+
uses: actions/setup-python@v4
22+
with:
23+
python-version: "3.11"
24+
25+
- name: Install Dependencies
26+
run: |
27+
pip install PyGithub
28+
29+
- name: Triage
30+
id: triage
1431
env:
1532
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1633
GH_REPO: ${{ github.repository }}
34+
GH_ISSUE: ${{ github.event.issue.number }}
35+
run: |
36+
python3 .github/scripts/issue-triage.py
37+

0 commit comments

Comments
 (0)