Add comments for trigger script
Signed-off-by: baalajimaestro <me@baalajimaestro.me>
This commit is contained in:
parent
264edabd8c
commit
bc299b676a
1 changed files with 9 additions and 2 deletions
11
trigger.py
11
trigger.py
|
@ -4,30 +4,37 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
#
|
#
|
||||||
|
|
||||||
|
# Imports
|
||||||
from git import Repo
|
from git import Repo
|
||||||
import subprocess
|
import subprocess
|
||||||
import os
|
import os
|
||||||
from time import time
|
from time import time
|
||||||
from requests import post
|
from requests import post
|
||||||
|
|
||||||
current_time = str(int(time()))
|
# Environment variables for creds
|
||||||
repo = Repo(os.getcwd())
|
|
||||||
base_repo_user = os.environ.get("BASE_REPO_USERNAME")
|
base_repo_user = os.environ.get("BASE_REPO_USERNAME")
|
||||||
base_repo_pass = os.environ.get("BASE_REPO_PASSWORD")
|
base_repo_pass = os.environ.get("BASE_REPO_PASSWORD")
|
||||||
content_repo_git = os.environ.get("CONTENT_REPO_GIT")
|
content_repo_git = os.environ.get("CONTENT_REPO_GIT")
|
||||||
content_repo_id = os.environ.get("CONTENT_REPO_ID")
|
content_repo_id = os.environ.get("CONTENT_REPO_ID")
|
||||||
gitlab_token = os.environ.get("GITLAB_TOKEN")
|
gitlab_token = os.environ.get("GITLAB_TOKEN")
|
||||||
|
|
||||||
|
# Get the time and create a tag of epoch
|
||||||
|
current_time = str(int(time()))
|
||||||
|
repo = Repo(os.getcwd())
|
||||||
repo.create_tag(current_time)
|
repo.create_tag(current_time)
|
||||||
|
|
||||||
|
# Nuke the remote if it existed
|
||||||
if repo.remote("pushback").exists():
|
if repo.remote("pushback").exists():
|
||||||
repo.remote().remove(repo, "pushback")
|
repo.remote().remove(repo, "pushback")
|
||||||
repo.create_remote(
|
repo.create_remote(
|
||||||
"pushback",
|
"pushback",
|
||||||
f"https://{base_repo_user}:{base_repo_pass}@git.baalajimaestro.me/baalajimaestro/{content_repo_git}.git",
|
f"https://{base_repo_user}:{base_repo_pass}@git.baalajimaestro.me/baalajimaestro/{content_repo_git}.git",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Push the newly created tag
|
||||||
repo.git.push("pushback", current_time)
|
repo.git.push("pushback", current_time)
|
||||||
|
|
||||||
|
# Trigger site rebuild
|
||||||
data = {"token": gitlab_token, "ref": "source"}
|
data = {"token": gitlab_token, "ref": "source"}
|
||||||
|
|
||||||
post(
|
post(
|
||||||
|
|
Loading…
Reference in a new issue