Skip to content

Commit

Permalink
Allow saving github creds in user folder (#14435)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlanCoding authored Sep 12, 2023
1 parent 56230ba commit 8feeb5f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
4 changes: 2 additions & 2 deletions docs/release_process.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ There are two methods you can use to get the next release version. The manual wa
Log into your github account, under your user icon go to Settings => Developer Settings => Personal Access Tokens => Tokens (classic).
Select the Generate new token => Generate new token (classic)
Fill in the note, select no scopes select "Generate token".
Copy the token and create a file in your awx repo called `.github_creds`. Enter the token in this file.
Copy the token and create a file at `~/.github_creds` or in your awx repo as `.github_creds`. Enter the token in this file.
Run `./tools/scripts/get_next_release.py`
This will use your token to go query for the PRs in the release and scan their bodies to select X/Y/Z and suggest new versions and spit out notifications.

Expand Down Expand Up @@ -149,7 +149,7 @@ Send notifications to the following groups:
* AWX Mailing List
* #social:ansible.com IRC (@newsbot for inclusion in bullhorn)
* #awx:ansible.com (no @newsbot in this room)
* #ansible-controller slack channel
* #ansible-controller slack channel

These messages are templated out for you in the output of `get_next_release.yml`.

Expand Down
27 changes: 14 additions & 13 deletions tools/scripts/get_next_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@
missing_modules = []
try:
import requests
except:
except ImportError:
missing_modules.append('requests')
import json
import os
import re
import sys
import time

try:
import semantic_version
except:
except ImportError:
missing_modules.append('semantic_version')

if len(missing_modules) > 0:
Expand Down Expand Up @@ -55,7 +53,7 @@ def getNextReleases():
try:
if a_pr['html_url'] in pr_votes:
continue
except:
except KeyError:
print("Unable to check on PR")
print(json.dumps(a_pr, indent=4))
sys.exit(255)
Expand Down Expand Up @@ -133,14 +131,17 @@ def getNextReleases():
# Load the users session information
#
session = requests.Session()
try:
print("Loading credentials")
with open(".github_creds", "r") as f:
password = f.read().strip()
session.headers.update({'Authorization': 'bearer {}'.format(password), 'Accept': 'application/vnd.github.v3+json'})
except Exception:
print("Failed to load credentials from ./.github_creds")
sys.exit(255)

print("Loading credentials")
CREDS_LOCATIONS = ('.github_creds', '~/.github_creds')
for creds_loc in CREDS_LOCATIONS:
if os.path.exists(os.path.expanduser(creds_loc)):
with open(os.path.expanduser(creds_loc), "r") as f:
password = f.read().strip()
session.headers.update({'Authorization': 'bearer {}'.format(password), 'Accept': 'application/vnd.github.v3+json'})
break
else:
raise Exception(f'Could not location github token in locations {CREDS_LOCATIONS}')

versions = {
'current': {},
Expand Down

0 comments on commit 8feeb5f

Please sign in to comment.