Set ssh keys manually on git

Signed-off-by: baalajimaestro <me@baalajimaestro.me>
This commit is contained in:
baalajimaestro 2023-06-18 18:48:07 +05:30
parent 0bacbf7241
commit 415d1a8a2f
Signed by: baalajimaestro
GPG key ID: F93C394FE9BBAFD5

View file

@ -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)