From 415d1a8a2fb5f5655ab133b208d9b97a45c2ffe2 Mon Sep 17 00:00:00 2001 From: baalajimaestro Date: Sun, 18 Jun 2023 18:48:07 +0530 Subject: [PATCH] Set ssh keys manually on git Signed-off-by: baalajimaestro --- encrypt.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/encrypt.py b/encrypt.py index 3bb4ed8..c9a4011 100644 --- a/encrypt.py +++ b/encrypt.py @@ -31,6 +31,9 @@ BLACKLIST = [ enc_path = os.environ.get("ENCRYPTED_PATH") enc_repo = os.environ.get("ENCRYPTED_REPO") enc_key = os.environ.get("ENCRYPTION_KEY") +ssh_key = os.environ.get("SSH_SECRET_KEY") + +git_ssh_cmd = f"ssh -o StrictHostKeyChecking=no -i {ssh_key}" # Create our encrypted directory base current_time = str(int(time())) @@ -43,7 +46,7 @@ os.chdir(enc_path) repo = Repo.init(enc_path) repo.create_remote( "origin", - f"git@github.com:{enc_repo}.git", + f"ssh://git@github.com/{enc_repo}.git", ) # Glob the file list of "." starting files and non "." starting files @@ -92,7 +95,7 @@ for i in file_list: # Add, commit and push it all repo.git.add(".") repo.index.commit(f"Commit as of {current_time}") -repo.git.push("origin", "master", force=True) +repo.git.push("origin", "master", force=True, env=dict(GIT_SSH_COMMAND=git_ssh_cmd)) # Cleanup once you are done rmtree(enc_path)