From 766974ea09d8b8038cbb35b84b0867831c4268da Mon Sep 17 00:00:00 2001 From: Kevin Kim Date: Thu, 21 Mar 2024 11:11:27 +0900 Subject: [PATCH] refactor: Change GITHUB_TOKEN to use .env --- gitlio/app/domain/repository/repository_router.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/gitlio/app/domain/repository/repository_router.py b/gitlio/app/domain/repository/repository_router.py index 756342b..58c7e1e 100644 --- a/gitlio/app/domain/repository/repository_router.py +++ b/gitlio/app/domain/repository/repository_router.py @@ -11,15 +11,19 @@ import requests from typing import List from urllib.parse import urlparse +from dotenv import load_dotenv, find_dotenv +import os + +load_dotenv(find_dotenv()) router = APIRouter( prefix="/api/repositories" ) # GitHub Personal Access Token -token = '토큰' +GITHUB_TOKEN = os.environ.get("GITHUB_TOKEN") headers = { - 'Authorization': f'token {token}', + 'Authorization': f'Bearer {GITHUB_TOKEN}', } @@ -122,7 +126,7 @@ def get_user_data(request: repository_schema.RepositoryCreateRequest, db: Sessio commit_messages = get_commit(org, repo, username) # 패키지 파일 내용 - package_files = ['requirements.txt', 'Pipfile', 'setup.py', 'build.gradle', 'pom.xml', 'package.json'] + package_files = ['requirements.txt', 'Pipfile', 'setup.py', 'build.gradle', 'pom.xml', 'package.json', 'go.mod'] package_path = find_package_file(org, repo, "", package_files) package_contents = get_package_contents(org, repo, package_path)