File size: 920 Bytes
8934152
 
 
75dd009
 
8934152
 
 
 
 
03bb562
 
 
8934152
0673cdf
8934152
 
 
 
75dd009
8934152
 
 
 
 
 
 
 
75dd009
 
 
1e1f179
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from git import Repo
import os
import subprocess
import sys


GITHUB_PAT = os.getenv('GITHUB_PAT')
GIT_USER = os.getenv('GIT_USER')
GIT_REPO = os.getenv('GIT_REPO')

if GITHUB_PAT:
    print("GITHUB_PAT set")

if not os.path.exists('cloned_repo'):
    Repo.clone_from(f'https://{GIT_USER}:{GITHUB_PAT}@github.com/{GIT_USER}/{GIT_REPO}.git', './cloned_repo')

# Install Python dependencies
subprocess.run(['pip', 'install', '-r', 'cloned_repo/requirements.txt'])


# Install system-level dependencies if packages.txt exists
if os.path.exists('cloned_repo/packages.txt'):
    with open('cloned_repo/packages.txt') as f:
        packages = f.read().splitlines()
        if packages:
            subprocess.run(['apt-get', 'update'])
            subprocess.run(['apt-get', 'install', '-y'] + packages)

sys.path.insert(0, os.path.abspath('cloned_repo'))

# Now you can import your modules correctly
import main 

main.main()