Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
hiroshinishio committed Nov 17, 2024
1 parent 6c23fa0 commit 77f4f4f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion services/github/actions_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import zipfile
import requests
from config import GITHUB_API_URL, TIMEOUT, UTF8
from services.github.github_manager import create_headers
from services.github.create_headers import create_headers
from utils.handle_exceptions import handle_exceptions


Expand Down
11 changes: 11 additions & 0 deletions services/github/create_headers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from config import GITHUB_API_VERSION, GITHUB_APP_NAME


def create_headers(token: str, media_type: str = ".v3") -> dict[str, str]:
"""https://docs.github.com/en/rest/using-the-rest-api/getting-started-with-the-rest-api?apiVersion=2022-11-28#headers"""
return {
"Accept": f"application/vnd.github{media_type}+json",
"Authorization": f"Bearer {token}",
"User-Agent": GITHUB_APP_NAME,
"X-GitHub-Api-Version": GITHUB_API_VERSION,
}
13 changes: 1 addition & 12 deletions services/github/github_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@
from config import (
EXCEPTION_OWNERS,
GITHUB_API_URL,
GITHUB_API_VERSION,
GITHUB_APP_ID,
GITHUB_APP_IDS,
GITHUB_APP_NAME,
GITHUB_ISSUE_DIR,
GITHUB_ISSUE_TEMPLATES,
GITHUB_PRIVATE_KEY,
Expand All @@ -40,6 +38,7 @@
SUPABASE_SERVICE_ROLE_KEY,
UTF8,
)
from services.github.create_headers import create_headers
from services.github.github_types import (
BaseArgs,
GitHubContentInfo,
Expand Down Expand Up @@ -298,16 +297,6 @@ def create_comment_on_issue_with_gitauto_button(payload: GitHubLabeledPayload) -
return response.json()


def create_headers(token: str, media_type: Optional[str] = ".v3") -> dict[str, str]:
"""https://docs.github.com/en/rest/using-the-rest-api/getting-started-with-the-rest-api?apiVersion=2022-11-28#headers"""
return {
"Accept": f"application/vnd.github{media_type}+json",
"Authorization": f"Bearer {token}",
"User-Agent": GITHUB_APP_NAME,
"X-GitHub-Api-Version": GITHUB_API_VERSION,
}


def create_jwt() -> str:
"""Generate a JWT (JSON Web Token) for GitHub App authentication"""
now = int(time.time())
Expand Down
2 changes: 1 addition & 1 deletion services/github/pulls_manager.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import requests
from config import GITHUB_API_URL, TIMEOUT, PER_PAGE
from services.github.github_manager import create_headers
from services.github.create_headers import create_headers
from services.github.github_types import BaseArgs
from utils.handle_exceptions import handle_exceptions

Expand Down

0 comments on commit 77f4f4f

Please sign in to comment.