in devai-api/app/github_utils.py [0:0]
def create_pull_request(prompt: str):
"""Creates a pull request on GitHub with updates to the README.md file.
Args:
prompt (str): The prompt describing the desired changes.
Returns:
The response from the GitHub API, or None if an error occurs.
"""
try:
validate_github_setup()
except Exception as e:
resp = "Error validating GitHub setup"
print(f"{resp}: {e}")
return resp
response = ""
try:
repo_name = os.environ["GITHUB_REPO_NAME"]
delete_folder(repo_name)
source_code = get_source_code(repo_name)
summary = get_summary(README_UPDATE_INSTRUCTIONS, source_code)
branch = "feature/docs-update"
file = "README.md"
response = create_github_pr(
branch,
{
file: summary,
},
)
return response
except Exception as e:
print(f"Failed to create pull request: {e}")
finally:
delete_folder(repo_name)
return response