-
Notifications
You must be signed in to change notification settings - Fork 4
update notes on script update with timestamp #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jgarcesres
wants to merge
5
commits into
main
Choose a base branch
from
8-update-script-notes
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2ad35a6
ignore local cache
jgarcesres 6437188
update notes on script update with timestamp
jgarcesres 1f01ac6
Update action.py
jgarcesres c8d154b
import timezone
jgarcesres 93c3cba
add commit hash to the note. roll both note functions into one
jgarcesres File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| action/test | ||
| .env | ||
| .DS_Store | ||
| *.code-workspace | ||
| *.code-workspace | ||
| __pycache__ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -7,6 +7,7 @@ | |||||
| import jmespath | ||||||
| import hashlib | ||||||
| import sys | ||||||
| from datetime import datetime, timezone | ||||||
| from loguru import logger | ||||||
|
|
||||||
| logger.remove() | ||||||
|
|
@@ -207,6 +208,53 @@ def compare_scripts(new, old): | |||||
| return False | ||||||
|
|
||||||
|
|
||||||
| #function to create or update notes with proper timestamping | ||||||
| @logger.catch | ||||||
| def update_script_notes(existing_notes, action_type="updated"): | ||||||
| timestamp = datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M:%S UTC") | ||||||
| commit_hash = os.getenv('GITHUB_SHA', 'unknown')[:7] # Get first 7 characters of commit hash | ||||||
| action_line = f"{action_type} via github action on {timestamp} (commit: {commit_hash})" | ||||||
|
|
||||||
| if not existing_notes: | ||||||
| # No existing notes, just add the action line | ||||||
| return action_line | ||||||
|
|
||||||
| lines = existing_notes.strip().split('\n') | ||||||
| updated_lines = [] | ||||||
| found_created_line = False | ||||||
| found_updated_line = False | ||||||
|
|
||||||
| # Look for existing github action lines | ||||||
| for line in lines: | ||||||
| line = line.strip() | ||||||
| if line.startswith("created via github action"): | ||||||
| if not found_created_line: | ||||||
| updated_lines.append(line) # Keep the original created line | ||||||
| found_created_line = True | ||||||
| # Skip duplicate created lines | ||||||
| elif line.startswith("updated via github action"): | ||||||
| if not found_updated_line: | ||||||
| updated_lines.append(action_line) # Replace with new updated line | ||||||
| found_updated_line = True | ||||||
| # Skip old updated lines | ||||||
| else: | ||||||
| # Keep other notes | ||||||
| if line: # Only add non-empty lines | ||||||
| updated_lines.append(line) | ||||||
|
|
||||||
| # If we didn't find an existing updated line, add it after created line (if exists) or at the top | ||||||
| if not found_updated_line: | ||||||
| if found_created_line: | ||||||
| # Insert after the created line | ||||||
| insert_index = 1 if len(updated_lines) > 0 else 0 | ||||||
| updated_lines.insert(insert_index, action_line) | ||||||
| else: | ||||||
| # Insert at the beginning | ||||||
| updated_lines.insert(0, action_line) | ||||||
|
|
||||||
| return '\n'.join(updated_lines) | ||||||
|
|
||||||
|
|
||||||
| #retrieves list of files given a folder path and the list of valid file extensions to look for | ||||||
|
||||||
| #retrieves list of files given a folder path and the list of valid file extensions to look for | |
| # Retrieves list of files given a folder path and the list of valid file extensions to look for. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment should start with a capital letter and end with a period: 'Function to create or update notes with proper timestamping.'