Debug
This commit is contained in:
parent
fe992c7e96
commit
0cca0db22f
@ -2,19 +2,19 @@ import os
|
||||
import yaml
|
||||
import subprocess
|
||||
|
||||
# 🔁 Repos to scan for monitoring.yaml files
|
||||
REPOS = {
|
||||
"dev-tools": "https://git.dvirlabs.com/dvirlabs/dev-tools.git",
|
||||
"infra": "https://git.dvirlabs.com/dvirlabs/infra.git",
|
||||
"observability-stack": "https://git.dvirlabs.com/dvirlabs/observability-stack.git",
|
||||
"sandbox": "https://git.dvirlabs.com/dvirlabs/sandbox.git",
|
||||
# ✅ Add GitHub repo to REPOS list (not hardcoded separately)
|
||||
"lab-monitor": f"https://{os.getenv('GITHUB_TOKEN')}@github.com/dvirlabs/lab-monitor.git",
|
||||
}
|
||||
|
||||
# ✅ CORRECT GitHub repo (lab-monitor, not apps-gitops)
|
||||
GITHUB_REPO = f"https://{os.getenv('GITHUB_TOKEN')}@github.com/dvirlabs/lab-monitor.git"
|
||||
|
||||
BASE_DIR = "./repos"
|
||||
WORKFLOW_FILE = "./repos/lab-monitor/.github/workflows/monitor.yml"
|
||||
REPO_PATH = os.path.join(BASE_DIR, "lab-monitor")
|
||||
WORKFLOW_FILE = os.path.join(REPO_PATH, ".github/workflows/monitor.yml")
|
||||
|
||||
|
||||
def clone_repos():
|
||||
@ -30,6 +30,8 @@ def clone_repos():
|
||||
def extract_urls():
|
||||
urls = []
|
||||
for repo in REPOS:
|
||||
if repo == "lab-monitor":
|
||||
continue # skip this, it's where we push
|
||||
manifests_path = os.path.join(BASE_DIR, repo, "manifests")
|
||||
if not os.path.isdir(manifests_path):
|
||||
continue
|
||||
@ -110,17 +112,15 @@ jobs:
|
||||
|
||||
|
||||
def push_workflow():
|
||||
# ✅ Clone lab-monitor repo from GitHub
|
||||
if not os.path.exists(REPO_PATH):
|
||||
print("📥 Cloning lab-monitor...")
|
||||
result = subprocess.run(["git", "clone", GITHUB_REPO, REPO_PATH])
|
||||
if result.returncode != 0:
|
||||
raise Exception("❌ Failed to clone lab-monitor repo")
|
||||
subprocess.run(["ls", "-l", REPO_PATH])
|
||||
|
||||
# ✅ Checkout main (GitHub default branch)
|
||||
subprocess.run(["git", "-C", REPO_PATH, "fetch"], check=True)
|
||||
subprocess.run(["git", "-C", REPO_PATH, "checkout", "main"], check=True)
|
||||
# Detect default branch (main or master)
|
||||
result = subprocess.run(
|
||||
["git", "-C", REPO_PATH, "symbolic-ref", "refs/remotes/origin/HEAD"],
|
||||
capture_output=True, text=True, check=True
|
||||
)
|
||||
default_branch = result.stdout.strip().split("/")[-1]
|
||||
subprocess.run(["git", "-C", REPO_PATH, "checkout", default_branch], check=True)
|
||||
|
||||
# Git identity
|
||||
subprocess.run(["git", "-C", REPO_PATH, "config", "user.name", "lab-monitor-bot"])
|
||||
@ -129,10 +129,10 @@ def push_workflow():
|
||||
# Add + Commit + Push
|
||||
subprocess.run(["git", "-C", REPO_PATH, "add", ".github/workflows/monitor.yml"])
|
||||
subprocess.run(["git", "-C", REPO_PATH, "commit", "-m", "update monitor.yml from monitoring.yaml"], check=False)
|
||||
result = subprocess.run(["git", "-C", REPO_PATH, "push", "--set-upstream", "origin", "main"])
|
||||
result = subprocess.run(["git", "-C", REPO_PATH, "push", "--set-upstream", "origin", default_branch])
|
||||
|
||||
if result.returncode != 0:
|
||||
raise Exception("❌ Failed to push monitor.yml to origin/main")
|
||||
raise Exception(f"❌ Failed to push monitor.yml to origin/{default_branch}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user