Skip to content

Commit

Permalink
📝 Chore(Actions): Only build on existing new commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dynesshely committed Oct 28, 2023
1 parent f7c80bd commit 296cf15
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions ToolKits/Actions/check_new_commit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import sys
import os
from datetime import datetime, timedelta, timezone

current_utc_time = datetime.utcnow()
current_utc_time = current_utc_time.replace(tzinfo=timezone.utc)

print("Args list: ", sys.argv)

time_str = sys.argv[1]
days_deference = int(sys.argv[2])

datetime_obj = datetime.fromisoformat(time_str)
datetime_obj = datetime_obj.replace(tzinfo=timezone.utc)

time_difference = current_utc_time - datetime_obj

print("Time delta: ", time_difference)

if time_difference > timedelta(days=days_deference):
print("No new commit found. Check in env var: [HAS_NEW_COMMIT].")
os.putenv("HAS_NEW_COMMIT", "false")
else:
print("New commit found. Check in env var: [HAS_NEW_COMMIT].")
os.putenv("HAS_NEW_COMMIT", "true")

0 comments on commit 296cf15

Please sign in to comment.