Skip to content

Instantly share code, notes, and snippets.

@vanessaaleung
Created May 2, 2021 23:11
Show Gist options
  • Save vanessaaleung/9924b096544189fcaea19ee3cdbf04a2 to your computer and use it in GitHub Desktop.
Save vanessaaleung/9924b096544189fcaea19ee3cdbf04a2 to your computer and use it in GitHub Desktop.
Add Label to GitHub PR
def add_pr_label(owner: str, repo: str, token: str, pull_number: str) -> None:
url = "https://api.github.com/repos/{}/{}/issues/{}/labels".format(owner, repo, pull_number)
headers = {
"Authorization": "token {}".format(token),
"Content-Type": "application/json"
}
payload = {
"labels" : ["driver"]
}
try:
requests.post(url, headers=headers, json=payload)
logging.info("Added label driver to PR")
except Exception as e:
logging.error(e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment