Last active
June 19, 2019 16:40
-
-
Save SiccarPoint/e829f9150e24812f7e4844688d9fabf5 to your computer and use it in GitHub Desktop.
Modify github issue assignees through API
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 | |
r = requests.get( | |
"https://api.github.com/search/issues", | |
params={ | |
"q": "fish+repo:SiccarPoint/stochastic-delta" | |
} # find the I am a fish issue | |
) | |
fishhue = r.json() | |
issue_url = fisshue['items'][0]['url'] # 0 index as only one issue has fish in it | |
payload = {'assignees': ['SiccarPoint', ]} | |
# now, go to | |
# Github user settings -> development settings -> Personal access tokens -> Generate new token | |
# Set up one with the appropriate scopes and copy the token string | |
requests.post(issue_url, json=payload, headers={'Authorization': 'token 6949ffgsdfjfdgd64545etcetcetc'}) | |
# this should now be set on the website, but could also check with | |
mynewfish = requests.get(issue_url).json() | |
mynewfish['assignees'][0]['login'] == 'SiccarPoint' | |
# ...a webhook could be added to trigger the run of a script like this every time an issue is created | |
# It could perhaps interact with a CODEOWNERS file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment