-
-
Save Aveline-art/fa5e50998e5dbaa11f0bdc11be010229 to your computer and use it in GitHub Desktop.
A program that creates an issue and pull request in a repository. Useful to test GHAs.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import json | |
import time | |
print('sleeping for 10 secs') | |
time.sleep(10) | |
link = 'https://api.github.com/repos/{INSERT_NAME_OF_OWNER}/{INSERT_NAME_OF_REPO}/issues' | |
headers = { | |
'Accept': 'application/vnd.github.v3+json', | |
'Authorization': 'token {INSERT_API_KEY_HERE}' | |
} | |
r1 = requests.post('https://api.github.com/repos/{INSERT_NAME_OF_OWNER}/{INSERT_NAME_OF_REPO}/issues', headers = headers, json = { | |
'title': 'this is a test', | |
'body': 'this is a body', | |
}) | |
print(r1.status_code) | |
r2 = requests.patch(json.loads(r1.text)['url'], headers = headers, json = { | |
'state': 'closed', | |
}) | |
print(r2.status_code) | |
r3 = requests.post('https://api.github.com/repos/{INSERT_NAME_OF_OWNER}/{INSERT_NAME_OF_REPO}/pulls', headers = headers, json = { | |
'title': 'this is a test', | |
'body': 'this is a body', | |
'head': 'main', | |
'base': {INSERT_NAME_OF_A_BRANCH}, | |
}) | |
print(r3.status_code) | |
r4 = requests.patch(json.loads(r3.text)['url'], headers = headers, json = { | |
'state': 'closed', | |
}) | |
print(r4.status_code) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment