Update trigger to use ssh as well

Signed-off-by: baalajimaestro <me@baalajimaestro.me>
This commit is contained in:
baalajimaestro 2023-06-18 19:21:27 +05:30
parent 415d1a8a2f
commit 906e948b6c
Signed by: baalajimaestro
GPG key ID: F93C394FE9BBAFD5

View file

@ -12,11 +12,12 @@ from requests import post
from pathlib import Path
# Environment variables for creds
base_repo_user = os.environ.get("BASE_REPO_USERNAME")
base_repo_pass = os.environ.get("BASE_REPO_PASSWORD")
content_repo_git = os.environ.get("CONTENT_REPO_GIT")
content_repo_id = os.environ.get("CONTENT_REPO_ID")
gitlab_token = os.environ.get("GITLAB_TOKEN")
ssh_key = os.environ.get("SSH_SECRET_KEY")
git_ssh_cmd = f"ssh -o StrictHostKeyChecking=no -i {ssh_key}"
# Get the time and create a tag of epoch
cwd = os.getcwd()
@ -32,11 +33,11 @@ except ValueError:
pass
repo.create_remote(
"pushback",
f"https://{base_repo_user}:{base_repo_pass}@git.baalajimaestro.me/{content_repo_git}.git",
f"ssh://git@git.baalajimaestro.me:29999/{content_repo_git}.git",
)
# Push the newly created tag
repo.git.push("pushback", "HEAD:prod", force=True)
repo.git.push("pushback", "HEAD:prod", force=True, env=dict(GIT_SSH_COMMAND=git_ssh_cmd))
# Trigger site rebuild
data = {"token": gitlab_token, "ref": "source"}