pythongithub3.py

Add image to pull request comment


I'm using the github3.py library to create a comment in a pull request from the columns field in a csv file. I would like to add an image to the comment along with the output from the columns, but I can't find a way to do this. I've read up on using PIL to open images, but .create_comment() only takes a string value. Any hints or pointers?

failed_validation_lst=[]
        with open(reportOut, 'r') as f:
            reader = csv.reader(f, skipinitialspace=True)
            headers = next(reader)
            for row_number,row in enumerate(reader,2):
                for column, val in enumerate(row):
                    if val == 'True':
                        failed_validation_lst.append(headers[column])
                failed_validation_string = '; '.join(failed_validation_lst)
                repo.issue(row[0]).create_comment(failed_validation_string)

Solution

  • The GitHub API does not support this. Commenting on a pull request is the same thing as commenting on a issue. You'll need to host the image elsewhere and use image tag markdown to display it, e.g.,

    ![image description](http://image-hosting.com/path/to/img.jpg)