mirror of
https://github.com/alexhopeoconnor/default.git
synced 2026-10-04 02:58:10 +10:00
36 lines
1.0 KiB
Python
36 lines
1.0 KiB
Python
import asyncio
|
|
import os
|
|
|
|
from scripts.changed.repo import get_repo
|
|
from scripts.helpers.event import get_event
|
|
from aiogithubapi import GitHub, AIOGitHubAPIException
|
|
|
|
TOKEN = os.getenv("GITHUB_TOKEN")
|
|
|
|
|
|
async def check():
|
|
print("Information: https://hacs.xyz/docs/publish/include#check-owner")
|
|
repo = get_repo()
|
|
event = get_event()
|
|
actor = event["pull_request"]["user"]["login"]
|
|
|
|
try:
|
|
async with GitHub(TOKEN) as github:
|
|
request = await github.client.get(
|
|
endpoint=f"/repos/{repo}/collaborators/{actor}/permission", headers={},
|
|
)
|
|
|
|
permission = request.get("permission", "read")
|
|
|
|
if permission in ["admin", "write"]:
|
|
print(f"{actor} is the owner of the repository")
|
|
return
|
|
except AIOGitHubAPIException as e:
|
|
exit(f"::error::{e}")
|
|
|
|
exit(f"::error::{actor} does not have write access to the repository")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.get_event_loop().run_until_complete(check())
|