From 3ca792fd149aa348dcb15b5df8d14592262cccef Mon Sep 17 00:00:00 2001 From: jgarcesres Date: Fri, 15 Sep 2023 10:18:10 -0400 Subject: [PATCH] simplify dupe check and fixed some typos and logging --- .github/workflows/pythonapp.yml | 8 +++----- action.py | 27 +++++++++++++-------------- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/.github/workflows/pythonapp.yml b/.github/workflows/pythonapp.yml index 9bfa87f..71b84d7 100644 --- a/.github/workflows/pythonapp.yml +++ b/.github/workflows/pythonapp.yml @@ -5,7 +5,7 @@ name: Python application on: push: - branches: [ master ] + #branches: [ master ] paths: - '**/*.py' pull_request: @@ -19,11 +19,9 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Set up Python 3.8 + - uses: actions/checkout@v3 + - name: Set up Python uses: actions/setup-python@v1 - with: - python-version: 3.8 - name: Install dependencies run: | python -m pip install --upgrade pip diff --git a/action.py b/action.py index 21c78a5..5cfce0e 100644 --- a/action.py +++ b/action.py @@ -242,19 +242,15 @@ def push_scripts(): scripts['github_simple_name'] = [] for script in scripts['github']: scripts['github_simple_name'].append(get_script_name(script).lower()) - - logger.info('doublechecking for duplicate names') - dupes = False + logger.info('doublechecking for duplicate script names') for count, script in enumerate(scripts['github_simple_name']): if scripts['github_simple_name'].count(script) >= 2: - dupes = True - logger.error("conflicting script name") - logger.error(scripts['github'][count]) - if dupes == True: - sys.exit(1) + logger.error(f"the script name {script} is duplicated {scripts['github_simple_name'].count(script)} times, please give it a unique name") + #logger.error(scripts['github'][count]) + sys.exit(1) #continue if no dupes are found - logger.success("found no duplicate script names, we can continue") - logger.info('now checking against jamf for the list of scripts') + logger.success("nice, no duplicate script names, we can continue") + logger.info('now checking jamf for its list of scripts') scripts['jamf'] = get_all_jamf_scripts(url, token) logger.info("setting all script names to lower case to avoid false positives in our search.") logger.info("worry not, this won't affect the actual naming :)") @@ -319,13 +315,16 @@ def push_ea_scripts(): if __name__ == "__main__": logger.info('reading environment variables') url = os.getenv('INPUT_JAMF_URL') - auth_type = os.getenv("INPUT_JAMF_AUTH_TYPE", "auth") + auth_type = os.getenv("INPUT_JAMF_AUTH_TYPE") if auth_type == "auth": username = os.getenv('INPUT_JAMF_USERNAME') password = os.getenv('INPUT_JAMF_PASSWORD') - else: + elif auth_type == "oauth": client_id = os.getenv("INPUT_JAMF_USERNAME") client_secret = os.getenv("INPUT_JAMF_PASSWORD") + else: + logger.error("no valid auth_type, use 'auth' or 'oauth'") + sys.exit(1) script_dir = os.getenv('INPUT_SCRIPT_DIR') ea_script_dir = os.getenv('INPUT_EA_SCRIPT_DIR') workspace_dir = os.getenv('GITHUB_WORKSPACE') @@ -340,12 +339,12 @@ def push_ea_scripts(): logger.info(f"workspace dir is: {workspace_dir}") logger.info(f"script_dir is: {script_dir}") logger.info(f"branch is set to: {branch}") - logger.info(f"script_deltion is: {delete}") + logger.info(f"script_deletion is: {delete}") logger.info(f"scripts_extensions are: {script_extensions}") if enable_prefix == 'false': logger.warning('prefix is disabled') else: - logger.warning('prefix is enabled') + logger.warning(f'prefix enabled, using: {branch.split('/')[-1]}') #run the block to push the "normal" scripts to jamf push_scripts() #check to see if we have an EA scripts to push over