Spaces:
Sleeping
Sleeping
| from os import environ, chdir | |
| from subprocess import run, PIPE | |
| # Install Demo Application | |
| run(["git", "clone", | |
| f"https://{environ['GITHUB_TOKEN']}@github.com/neongeckocom/brainforge-webapp", | |
| "-b", environ["GITHUB_BRANCH"]]) | |
| # Replace SSH dependencies with HTTP using token envvar | |
| requirements_file = "./brainforge-webapp/requirements/requirements.txt" | |
| with open(requirements_file, 'r') as f: | |
| lines = f.readlines() | |
| for idx, line in enumerate(lines): | |
| if "git+ssh://git@github.com" in line: | |
| lines[idx] = line.replace("git+ssh://git@github.com", f"git+https://{environ['GITHUB_TOKEN']}@github.com") | |
| with open(requirements_file, 'w') as f: | |
| f.writelines(lines) | |
| run(["pip", "install", "./brainforge-webapp"]) | |
| # Get Demo Commit ID | |
| chdir("brainforge-webapp") | |
| commit = run(["git", "rev-parse", "--short", "HEAD"], stdout=PIPE).stdout.decode('utf-8').strip() | |
| environ["GH_COMMIT"] = commit | |
| from brainforge_webapp.app import run | |
| run() | |