From 296cf15cbb2634f75efa0bfed23765ac5369643b Mon Sep 17 00:00:00 2001 From: Dynesshely Date: Sun, 29 Oct 2023 01:15:06 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20Chore(Actions):=20Only=20build?= =?UTF-8?q?=20on=20existing=20new=20commit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ToolKits/Actions/check_new_commit.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 ToolKits/Actions/check_new_commit.py diff --git a/ToolKits/Actions/check_new_commit.py b/ToolKits/Actions/check_new_commit.py new file mode 100644 index 0000000..5aa5769 --- /dev/null +++ b/ToolKits/Actions/check_new_commit.py @@ -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")