def pull_request_to_github(main_repo_user, repo_name, environment):
#Creating strings, mainly URLs, that will be needed for the
#pull request process.
#This is the API URL to make a pull request
pull_request_url = ('https://api.github.com/repos/{}/{}/pulls'.format(
main_repo_user, repo_name))
#This has the username and password from the environment file.
#It is used to log in for API calls.
auth_string = ('{}:{}'.format(environment['github_username'],
environment['github_password']))
#This is the data that will be posted for the pull request.
#It tells the API what the pull request will be like.
pull_request_data = ('{{"title": "{}", "head": "{}:master",'
' "base": "master"}}'.format(
environment['github_pull_request_title'],
environment['github_username']))
pull_request_command = ['curl', '--user', auth_string, pull_request_url,
'-d', pull_request_data]
#Make the pull request to the main repository
subprocess.check_output(pull_request_command)
return pull_request_command
评论列表
文章目录