Skip to content

Commit

Permalink
Read GITHUB repo and owner name from environment variables
Browse files Browse the repository at this point in the history
  • Loading branch information
AnandInguva committed Sep 26, 2023
1 parent 5d292a9 commit 5adaf4f
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions sdks/python/apache_beam/testing/analyzers/github_issues_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
'A Github Personal Access token is required '
'to create Github Issues.')

_BEAM_GITHUB_REPO_OWNER = 'apache'
_BEAM_GITHUB_REPO_NAME = 'beam'
_GITHUB_REPO_OWNER = os.environ.get('REPO_OWNER', 'AnandInguva')
_GITHUB_REPO_NAME = os.environ.get('REPO_NAME', 'beam')
# Adding GitHub Rest API version to the header to maintain version stability.
# For more information, please look at
# https://github.blog/2022-11-28-to-infinity-and-beyond-enabling-the-future-of-githubs-rest-api-with-api-versioning/ # pylint: disable=line-too-long
Expand Down Expand Up @@ -77,10 +77,10 @@ def create_issue(
Tuple containing GitHub issue number and issue URL.
"""
url = "https://api.github.com/repos/{}/{}/issues".format(
_BEAM_GITHUB_REPO_OWNER, _BEAM_GITHUB_REPO_NAME)
_GITHUB_REPO_OWNER, _GITHUB_REPO_NAME)
data = {
'owner': _BEAM_GITHUB_REPO_OWNER,
'repo': _BEAM_GITHUB_REPO_NAME,
'owner': _GITHUB_REPO_OWNER,
'repo': _GITHUB_REPO_NAME,
'title': title,
'body': description,
'labels': [_AWAITING_TRIAGE_LABEL, _PERF_ALERT_LABEL]
Expand Down Expand Up @@ -108,20 +108,20 @@ def comment_on_issue(issue_number: int,
issue, and the comment URL.
"""
url = 'https://api.github.com/repos/{}/{}/issues/{}'.format(
_BEAM_GITHUB_REPO_OWNER, _BEAM_GITHUB_REPO_NAME, issue_number)
_GITHUB_REPO_OWNER, _GITHUB_REPO_NAME, issue_number)
open_issue_response = requests.get(
url,
json.dumps({
'owner': _BEAM_GITHUB_REPO_OWNER,
'repo': _BEAM_GITHUB_REPO_NAME,
'owner': _GITHUB_REPO_OWNER,
'repo': _GITHUB_REPO_NAME,
'issue_number': issue_number
},
default=str),
headers=_HEADERS).json()
if open_issue_response['state'] == 'open':
data = {
'owner': _BEAM_GITHUB_REPO_OWNER,
'repo': _BEAM_GITHUB_REPO_NAME,
'owner': _GITHUB_REPO_OWNER,
'repo': _GITHUB_REPO_NAME,
'body': comment_description,
issue_number: issue_number,
}
Expand All @@ -134,7 +134,7 @@ def comment_on_issue(issue_number: int,

def add_awaiting_triage_label(issue_number: int):
url = 'https://api.github.com/repos/{}/{}/issues/{}/labels'.format(
_BEAM_GITHUB_REPO_OWNER, _BEAM_GITHUB_REPO_NAME, issue_number)
_GITHUB_REPO_OWNER, _GITHUB_REPO_NAME, issue_number)
requests.post(
url, json.dumps({'labels': [_AWAITING_TRIAGE_LABEL]}), headers=_HEADERS)

Expand Down

0 comments on commit 5adaf4f

Please sign in to comment.