Created
July 18, 2023 07:36
-
-
Save ruivieira/f846ee5c9e7ed189c978682f9f1e7f4b to your computer and use it in GitHub Desktop.
Closed issues from GitHub milestone to Markdown
This file contains hidden or 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 os | |
| # GitHub API URL | |
| url = 'https://api.github.com/repos/{owner}/{repo}/issues' | |
| # Replace these with the appropriate values | |
| owner = 'trustyai-explainability' | |
| repo = 'trustyai-explainability' | |
| milestone_number = 5 # replace with your milestone number | |
| # Add a token as a GITHUB_TOKEN env var (or replace below) | |
| # Headers with token | |
| headers = { | |
| 'Accept': 'application/vnd.github.v3+json', | |
| 'Authorization': f'token {os.getenv("GITHUB_TOKEN")}', | |
| } | |
| # Parameters for the request | |
| params = { | |
| 'state': 'closed', # Change to 'open' to get open issues | |
| 'milestone': milestone_number, | |
| } | |
| # Send a GET request | |
| response = requests.get(url.format(owner=owner, repo=repo), headers=headers, params=params) | |
| # Print the result if the request was successful | |
| if response.status_code == 200: | |
| print(f'Issues for {owner}/{repo}, milestone {milestone_number}:') | |
| data = response.json() | |
| for i, issue in enumerate(data, 1): | |
| print(f'{i}. {issue["title"]} ([#{issue["number"]}]({issue["html_url"]}))') | |
| else: | |
| print(f'Failed to get issues with: {response.content}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment