From 6be819589203ce876c27be641ef067bcc37c1277 Mon Sep 17 00:00:00 2001 From: Mikkel Troels Kongsted Date: Fri, 7 Mar 2025 11:26:41 +0100 Subject: [PATCH] add deploy cron job script --- deploy/deploy_cron_job.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 deploy/deploy_cron_job.py diff --git a/deploy/deploy_cron_job.py b/deploy/deploy_cron_job.py new file mode 100644 index 0000000..aba15b4 --- /dev/null +++ b/deploy/deploy_cron_job.py @@ -0,0 +1,27 @@ +#!/bin/python3 + +import time +import os + +def main(): + deployed_commit_hash = "" + while True: + newest_commit_hash = os.popen("curl -s https://api.github.com/repos/Mercantec-GHC/h4-projekt-gruppe-0-sm/commits/main | jq -r .sha").read() + + if not newest_commit_hash: + print("error fetching commit hash") + time.sleep(60) + continue + + if newest_commit_hash != deployed_commit_hash: + deployed_commit_hash = newest_commit_hash + print("should redeploy") + else: + print("should not redeploy") + + + time.sleep(60) + +if __name__ == "__main__": + main() +