From ba8c9794f715c21829f6af2a3527ce627383d240 Mon Sep 17 00:00:00 2001 From: benoit74 Date: Mon, 30 Oct 2023 08:25:16 +0100 Subject: [PATCH] Do not request Github environment variables when not needed --- .../maint-scripts/report_youtube_api_keys.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/dispatcher/backend/maint-scripts/report_youtube_api_keys.py b/dispatcher/backend/maint-scripts/report_youtube_api_keys.py index f8d0a71b..64bf235e 100755 --- a/dispatcher/backend/maint-scripts/report_youtube_api_keys.py +++ b/dispatcher/backend/maint-scripts/report_youtube_api_keys.py @@ -28,11 +28,19 @@ def report_youtube_api_keys(session: so.Session, *, display_unknown_secrets=False): jinja_env = Environment(loader=FileSystemLoader("./"), autoescape=True) jinja_template = jinja_env.get_template("report_youtube_api_keys.txt") - github_repo = os.environ["GITHUB_REPO"] - github_token = os.environ["GITHUB_TOKEN"] - github_issue_assignees = os.environ.get("GITHUB_ISSUE_ASSIGNEES", "").split(",") - github_issue_labels = os.environ.get("GITHUB_ISSUE_LABELS", "").split(",") create_issue = os.environ.get("CREATE_ISSUE", "false").lower() == "true" + github_repo = os.environ["GITHUB_REPO"] if create_issue else "nevermind" + github_token = os.environ["GITHUB_TOKEN"] if create_issue else "nevermind" + github_issue_assignees = ( + os.environ.get("GITHUB_ISSUE_ASSIGNEES", "").split(",") + if create_issue + else "nevermind" + ) + github_issue_labels = ( + os.environ.get("GITHUB_ISSUE_LABELS", "").split(",") + if create_issue + else "nevermind" + ) known_api_keys = json.loads( pathlib.Path("report_youtube_api_keys.conf.json").read_text()