Skip to content

Commit

Permalink
Changed logic about how to pass GH Token to GithhubDraftReleaseCreator
Browse files Browse the repository at this point in the history
  • Loading branch information
tomuben committed May 13, 2022
1 parent 404955a commit 832b589
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ def start_test_release_build(
release artifacts onto the new Github release.
"""
set_log_level(log_level)
run_start_test_release_build(AwsAccess(aws_profile), GithubDraftReleaseCreator(), repo_name,
project, branch, release_title, os.getenv("GITHUB_TOKEN"))
run_start_test_release_build(AwsAccess(aws_profile), GithubDraftReleaseCreator(),
repo_name, project, branch, release_title, os.getenv("GITHUB_TOKEN"))
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import os

from github import Github


Expand All @@ -10,11 +8,9 @@ class GithubDraftReleaseCreator(object):
The access token needs to be stored in the environment variable GITHUB_TOKEN.
Returns the internal ID of the new release.
"""
def __init__(self):
self._token = os.getenv("GITHUB_TOKEN")

def create_release(self, repo_name: str, branch: str, title: str) -> int:
gh = Github(self._token)
def create_release(self, repo_name: str, branch: str, title: str, gh_token: str) -> int:
gh = Github(gh_token)
gh_repo = gh.get_repo(repo_name)
release = gh_repo.create_git_release(tag="", name=title, message="Test-Release",
draft=True, prerelease=True, target_commitish=branch)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,5 @@ def run_start_test_release_build(aws_access: AwsAccess, gh_release_creator: Gith
project: str, branch: str, release_title: str, gh_token: str) -> None:
logging.info(f"run_start_test_release_build for aws profile {aws_access.aws_profile_for_logging} "
f"for project {project} for branch: {branch} with title: {release_title}")
release_id = gh_release_creator.create_release(repo_name, branch, release_title)
release_id = gh_release_creator.create_release(repo_name, branch, release_title, gh_token)
_execute_release_build(aws_access, project, branch, release_id, True, gh_token)
1 change: 0 additions & 1 deletion test/test_start_test_release_build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import datetime
import os
from unittest.mock import MagicMock

from dateutil.tz import tzutc
Expand Down

0 comments on commit 832b589

Please sign in to comment.