salla-gitpuller 0.1.1__tar.gz → 0.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {salla_gitpuller-0.1.1 → salla_gitpuller-0.1.2}/PKG-INFO +1 -1
- {salla_gitpuller-0.1.1 → salla_gitpuller-0.1.2}/gitpuller/gitpull.py +40 -2
- {salla_gitpuller-0.1.1 → salla_gitpuller-0.1.2}/pyproject.toml +1 -1
- {salla_gitpuller-0.1.1 → salla_gitpuller-0.1.2}/salla_gitpuller.egg-info/PKG-INFO +1 -1
- {salla_gitpuller-0.1.1 → salla_gitpuller-0.1.2}/LICENSE +0 -0
- {salla_gitpuller-0.1.1 → salla_gitpuller-0.1.2}/README.md +0 -0
- {salla_gitpuller-0.1.1 → salla_gitpuller-0.1.2}/gitpuller/__init__.py +0 -0
- {salla_gitpuller-0.1.1 → salla_gitpuller-0.1.2}/gitpuller/utils.py +0 -0
- {salla_gitpuller-0.1.1 → salla_gitpuller-0.1.2}/salla_gitpuller.egg-info/SOURCES.txt +0 -0
- {salla_gitpuller-0.1.1 → salla_gitpuller-0.1.2}/salla_gitpuller.egg-info/dependency_links.txt +0 -0
- {salla_gitpuller-0.1.1 → salla_gitpuller-0.1.2}/salla_gitpuller.egg-info/top_level.txt +0 -0
- {salla_gitpuller-0.1.1 → salla_gitpuller-0.1.2}/setup.cfg +0 -0
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import os
|
|
2
|
+
import requests
|
|
2
3
|
import subprocess
|
|
3
4
|
from typing import Any, Dict
|
|
4
5
|
|
|
5
6
|
|
|
6
|
-
def git_pull(repo_path: str, workspace_name: str, git_url: str, key_material: str) -> Dict[str, Any]:
|
|
7
|
+
def git_pull(repo_path: str, workspace_name: str, git_url: str, key_material: str, webhook_url: str) -> Dict[str, Any]:
|
|
7
8
|
"""
|
|
8
9
|
Executes 'git pull' in the specified repository path using a deploy key
|
|
9
10
|
provided via the env var WP_AUTOPULL_SSHKEY.
|
|
@@ -18,6 +19,38 @@ def git_pull(repo_path: str, workspace_name: str, git_url: str, key_material: st
|
|
|
18
19
|
print(f"Running git pull for workspace: {workspace_name}")
|
|
19
20
|
print(f"Repo path: {repo_path}")
|
|
20
21
|
|
|
22
|
+
repo_name = git_url.split('/')[-1].replace('.git', '')
|
|
23
|
+
|
|
24
|
+
if not all([webhook_url]):
|
|
25
|
+
raise EnvironmentError(
|
|
26
|
+
"One or more Slack environment variables are missing:\n"
|
|
27
|
+
"CDM_SLACK_WEBHOOK_URL"
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
payload = {
|
|
31
|
+
"text": f"Automate Git Pull Pipeline Failed",
|
|
32
|
+
"blocks": [
|
|
33
|
+
{
|
|
34
|
+
"type": "header",
|
|
35
|
+
"text": {
|
|
36
|
+
"type": "plain_text",
|
|
37
|
+
"text": f":alert: Automate Git Pull Pipeline Failed :alert:"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"type": "divider"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"type": "section",
|
|
45
|
+
"text": {
|
|
46
|
+
"type": "mrkdwn",
|
|
47
|
+
"text": f"*Repository:* `{repo_name}`"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
]
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
|
|
21
54
|
if not os.path.exists(repo_path):
|
|
22
55
|
raise FileNotFoundError(f"Repo path does not exist: {repo_path}")
|
|
23
56
|
|
|
@@ -38,7 +71,7 @@ def git_pull(repo_path: str, workspace_name: str, git_url: str, key_material: st
|
|
|
38
71
|
key_material += "\n"
|
|
39
72
|
|
|
40
73
|
ssh_dir = os.path.expanduser("~/.ssh")
|
|
41
|
-
key_path = os.path.join(ssh_dir, "
|
|
74
|
+
key_path = os.path.join(ssh_dir, "SallaApp_mageai_CI_CD_deploy")
|
|
42
75
|
os.makedirs(ssh_dir, exist_ok=True)
|
|
43
76
|
os.chmod(ssh_dir, 0o700)
|
|
44
77
|
|
|
@@ -63,6 +96,11 @@ def git_pull(repo_path: str, workspace_name: str, git_url: str, key_material: st
|
|
|
63
96
|
except subprocess.CalledProcessError as e:
|
|
64
97
|
git_output = (e.stdout or "") + (e.stderr or "")
|
|
65
98
|
git_status = "error"
|
|
99
|
+
payload["blocks"].append({
|
|
100
|
+
"type": "section",
|
|
101
|
+
"text": {"type": "mrkdwn", "text": f"*Error Output:*\n```{git_output[:1500]}```"} # truncate for Slack limit
|
|
102
|
+
})
|
|
103
|
+
requests.post(webhook_url, json=payload)
|
|
66
104
|
finally:
|
|
67
105
|
try:
|
|
68
106
|
os.remove(key_path)
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "salla_gitpuller"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.2"
|
|
8
8
|
description = "A lightweight utility to git pull a repository using SSH deploy keys stored in environment variables"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
authors = [
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{salla_gitpuller-0.1.1 → salla_gitpuller-0.1.2}/salla_gitpuller.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|