Skip to content

Commit 93c3cba

Browse files
committed
add commit hash to the note. roll both note functions into one
1 parent c8d154b commit 93c3cba

1 file changed

Lines changed: 3 additions & 9 deletions

File tree

action.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -208,18 +208,12 @@ def compare_scripts(new, old):
208208
return False
209209

210210

211-
#function to create a creation note with timestamp
212-
@logger.catch
213-
def create_creation_note():
214-
timestamp = datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M:%S UTC")
215-
return f"created via github action on {timestamp}"
216-
217-
218211
#function to create or update notes with proper timestamping
219212
@logger.catch
220213
def update_script_notes(existing_notes, action_type="updated"):
221214
timestamp = datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M:%S UTC")
222-
action_line = f"{action_type} via github action on {timestamp}"
215+
commit_hash = os.getenv('GITHUB_SHA', 'unknown')[:7] # Get first 7 characters of commit hash
216+
action_line = f"{action_type} via github action on {timestamp} (commit: {commit_hash})"
223217

224218
if not existing_notes:
225219
# No existing notes, just add the action line
@@ -330,7 +324,7 @@ def push_scripts():
330324
logger.info("it doesn't exist, lets create it")
331325
#it doesn't exist, we can create it
332326
with open(script, 'r') as upload_script:
333-
creation_note = create_creation_note()
327+
creation_note = update_script_notes("", "created")
334328
payload = {"name": script_name, "info": "", "notes": creation_note, "priority": "AFTER" , "categoryId": "1", "categoryName":"", "parameter4":"", "parameter5":"", "parameter6":"", "parameter7":"", "parameter8":"", "parameter9":"", "parameter10":"", "parameter11":"", "osRequirements":"", "scriptContents":f"{upload_script.read()}"}
335329
create_jamf_script(url, token, payload)
336330
elif len(script_search) == 1:

0 commit comments

Comments
 (0)