From 377ac1be65d47286a3db64ee334cfa3482465a39 Mon Sep 17 00:00:00 2001 From: Mathew Payne <2772944+GeekMasher@users.noreply.github.com> Date: Mon, 12 Aug 2024 09:34:10 +0000 Subject: [PATCH 1/2] feat: Add GHA retry --- ghascompliance/policy.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/ghascompliance/policy.py b/ghascompliance/policy.py index 6ee65ec..751f2f7 100644 --- a/ghascompliance/policy.py +++ b/ghascompliance/policy.py @@ -1,13 +1,14 @@ import os import json -from ghastoolkit.octokit.github import Dict -from ghastoolkit.octokit.octokit import Repository import yaml import shutil import fnmatch import datetime import tempfile -from typing import List, Optional +from typing import List, Dict, Optional + +from ghastoolkit import Repository + from ghascompliance.consts import SEVERITIES, TECHNOLOGIES, LICENSES from ghascompliance.octokit import Octokit @@ -76,6 +77,13 @@ def loadFromRepo(self): Octokit.info(f"Cloning policy repo - {self.repository}") self.repository.clone(clobber=True, depth=1) + if not os.path.exists(self.repository.clone_path) and not self.repository.is_github_app_token: + # Try as a GitHub App Token + Octokit.info("Retrying as GitHub App Token") + + self.repository.is_github_app_token = True + self.repository.clone(clobber=True, depth=1) + if not os.path.exists(self.repository.clone_path): raise Exception("Repository failed to clone") From 710705d33bb4b500c6bd9f779b1bae4f8781b9f2 Mon Sep 17 00:00:00 2001 From: Mathew Payne <2772944+GeekMasher@users.noreply.github.com> Date: Mon, 12 Aug 2024 15:06:18 +0000 Subject: [PATCH 2/2] feat: Update formatting --- ghascompliance/policy.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ghascompliance/policy.py b/ghascompliance/policy.py index 751f2f7..cbaf1c9 100644 --- a/ghascompliance/policy.py +++ b/ghascompliance/policy.py @@ -77,7 +77,10 @@ def loadFromRepo(self): Octokit.info(f"Cloning policy repo - {self.repository}") self.repository.clone(clobber=True, depth=1) - if not os.path.exists(self.repository.clone_path) and not self.repository.is_github_app_token: + if ( + not os.path.exists(self.repository.clone_path) + and not self.repository.is_github_app_token + ): # Try as a GitHub App Token Octokit.info("Retrying as GitHub App Token")