Skip to content

Commit

Permalink
simplify dupe check and fixed some typos and logging
Browse files Browse the repository at this point in the history
  • Loading branch information
jgarcesres authored Sep 15, 2023
1 parent 2668d3c commit 3ca792f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 19 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/pythonapp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ name: Python application

on:
push:
branches: [ master ]
#branches: [ master ]
paths:
- '**/*.py'
pull_request:
Expand All @@ -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
Expand Down
27 changes: 13 additions & 14 deletions action.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 :)")
Expand Down Expand Up @@ -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')
Expand All @@ -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
Expand Down

0 comments on commit 3ca792f

Please sign in to comment.