obsidian-support-scripts/trigger.py
baalajimaestro f94546bf64
License under AGPL-3
Signed-off-by: baalajimaestro <me@baalajimaestro.me>
2022-09-25 13:01:53 +05:30

29 lines
881 B
Python

#
# Copyright © 2022 Maestro Creativescape
#
# SPDX-License-Identifier: AGPL-3.0-or-later
#
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)