Pull in everything from private repo
Signed-off-by: baalajimaestro <me@baalajimaestro.me>
This commit is contained in:
commit
2a50fe7a66
2 changed files with 90 additions and 0 deletions
67
.encrypt.py
Normal file
67
.encrypt.py
Normal file
|
@ -0,0 +1,67 @@
|
|||
from git import Repo
|
||||
import os
|
||||
from shutil import copytree
|
||||
from glob import glob
|
||||
import subprocess
|
||||
from time import time
|
||||
|
||||
BLACKLIST = [".git", ".obsidian", ".idea", ".gitlab-ci.yml", ".encrypt.py", ".trigger.py"]
|
||||
|
||||
enc_path = os.environ.get("ENCRYPTED_PATH")
|
||||
enc_repo = os.environ.get("ENCRYPTED_REPO")
|
||||
enc_repo_user = os.environ.get("ENCRYPTED_REPO_USERNAME")
|
||||
enc_repo_pass = os.environ.get("ENCRYPTED_REPO_PASSWORD")
|
||||
enc_key = os.environ.get("ENCRYPTION_KEY")
|
||||
base_dir = os.getcwd()
|
||||
|
||||
current_time = str(int(time()))
|
||||
|
||||
os.mkdir(enc_path)
|
||||
os.chdir(enc_path)
|
||||
|
||||
repo = Repo.init(enc_path)
|
||||
repo.create_remote("origin", f"https://{enc_repo_user}:{enc_repo_pass}@github.com/baalajimaestro/{enc_repo}.git")
|
||||
|
||||
file_list = glob(base_dir+'/**/.*', recursive=True) + glob(base_dir+'/**/*', recursive=True)
|
||||
|
||||
for i in file_list:
|
||||
if os.path.isdir(i):
|
||||
rel_path = i.split(base_dir+"/")[1]
|
||||
for j in BLACKLIST:
|
||||
if rel_path in j:
|
||||
break
|
||||
else:
|
||||
os.mkdir(enc_path + "/" + rel_path)
|
||||
|
||||
for i in file_list:
|
||||
rel_path = i.split(base_dir+"/")[1]
|
||||
if not os.path.isdir(i):
|
||||
for j in BLACKLIST:
|
||||
if rel_path in j:
|
||||
break
|
||||
else:
|
||||
process = subprocess.run(
|
||||
["openssl",
|
||||
"enc",
|
||||
"-chacha20",
|
||||
"-base64",
|
||||
"-salt",
|
||||
"-iter",
|
||||
"1000",
|
||||
"-pass",
|
||||
f"pass:{enc_key}",
|
||||
"-md",
|
||||
"sha512",
|
||||
"-in",
|
||||
i,
|
||||
"-out",
|
||||
enc_path+"/"+rel_path]
|
||||
)
|
||||
|
||||
repo.git.add(".")
|
||||
|
||||
repo.index.commit(
|
||||
f"Commit as of {current_time}"
|
||||
)
|
||||
|
||||
repo.git.push('origin', 'master', force=True)
|
23
trigger.py
Normal file
23
trigger.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
from git import Repo
|
||||
import subprocess
|
||||
import os
|
||||
from time import time
|
||||
from requests import post
|
||||
|
||||
current_time = str(int(time()))
|
||||
repo = Repo(os.getcwd())
|
||||
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")
|
||||
gitlab_token = os.environ.get("GITLAB_TOKEN")
|
||||
|
||||
repo.create_tag(current_time)
|
||||
|
||||
if repo.remote("pushback").exists():
|
||||
repo.remote().remove(repo, "pushback")
|
||||
repo.create_remote("pushback", f"https://{base_repo_user}:{base_repo_pass}@git.baalajimaestro.me/baalajimaestro/{content_repo_git}.git")
|
||||
repo.git.push('pushback', current_time)
|
||||
|
||||
data = {"token": gitlab_token, "ref": "source"}
|
||||
|
||||
post("https://git.baalajimaestro.me/api/v4/projects/7/trigger/pipeline", json = data)
|
Loading…
Reference in a new issue