Skip to content

Instantly share code, notes, and snippets.

@vi-kas
Created July 9, 2019 10:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vi-kas/101463d46b47b356220e7df4945742a2 to your computer and use it in GitHub Desktop.
Save vi-kas/101463d46b47b356220e7df4945742a2 to your computer and use it in GitHub Desktop.
Script to create a Github Issue
import os
import sys
print(sys.version)
print("\n \n")
print(sys.path)
sys.path.append('/usr/local/lib/python3.7/site-packages')
import json
import requests
import pandas as pd
# Set environment variables for below
# export GITHUB_USER=YOUR_GITHUB_USER
# export GITHUB_TOKEN=YOUR_ACCESS_TOKEN
# In this file Issue and Title and Labels are customized. See Line 75, 76
# Authentication for user filing issue (must have read/write access to
# repository to add issue to)
USERNAME = os.environ['GITHUB_USER']
TOKEN = os.environ['GITHUB_TOKEN']
# The repository to add this issue to
REPO_OWNER = USERNAME
REPO_NAME = 'zen' # Give Repository name
def make_github_issue(title, labels=None, body=None, assignee=None, milestone=None):
# Create an issue on github.com using the given parameters
# Url to create issues via POST
url = 'https://github.com/api/v3/repos/%s/%s/issues' % (REPO_OWNER, REPO_NAME)
print('url: ' + url)
# Headers
head = {'Authorization': 'token {}'.format(TOKEN)}
# CRT Certificate to Request a Secure URL
respGet = requests.request("GET", url, verify="./XYZ Global Root CA.crt")
print(respGet)
# Create our issue
data = {
'title': title,
# 'body': body,
'labels': labels
#'assignees': [assignee]
}
payload = json.dumps(data)
print('title: "%s"' % title)
print('labels: "%s"' % labels)
print('payload: ' + payload)
# Add the issue to our repository
response = requests.request("POST", url, data=payload, headers=head, verify="./XYZ Global Root CA.crt")
if response.status_code == 201:
print('Successfully created Issue "%s"' % title)
else:
print ('response status: "%s"' % response.status_code)
print ('Could not create Issue "%s"' % title)
print ('Response:', response.content)
# title = 'Issue title'
# body = 'Issue body'
# labels = [
# "bug", "critical"
# ]
# domains = ["Worker", "Customer", "OrgStructure"]
# criterias = ["Align something", "XYZ review", "test criteria"]
domain_df = pd.read_csv('domains.csv')
criteria_df = pd.read_csv('criteria.csv')
# For a generic Issue creation we only need title, and labels.
for domain in domain_df['domains']:
for criteria in criteria_df['criteria']:
title = "[%s] %s" % (domain, criteria)
label = "reporting: %s" % criteria
make_github_issue(title, [label])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment