Skip to content
This repository was archived by the owner on Jun 22, 2024. It is now read-only.

Commit a8ba0af

Browse files
Added some error handling to the access token script, in case environment variables aren't set properly, so error messages are more helpful. [deploy]
1 parent 2f65fc3 commit a8ba0af

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ jobs:
187187
- run:
188188
name: "Check if branch is deployable (contains [deploy] in commit msg on $DEPLOY_BRANCH"
189189
command: |
190-
export CI_DEPLOY=`git log --format=oneline -n 1 | grep '\[deploy\]'` && echo $CI_DEPLOY
190+
export CI_DEPLOY=`git log --format=oneline -n 1 | grep '\[deploy\]'` && echo "$CI_DEPLOY"
191191
if [ -z "$CI_DEPLOY" ] || [ "$CIRCLE_BRANCH" != "$DEPLOY_BRANCH" ]; then
192192
echo "Cancelling run. Pass [deploy] in commit message on $DEPLOY_BRANCH to deploy"
193193
circleci-agent step halt

get-access-token.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@
1010
private_key = os.environ.get('GITHUB_APP_PEM')
1111
private_key = private_key.replace("\\n", "\n")
1212

13+
standard_error_msg = 'Seleniarm GitHub App installation environment variables are not set. '
14+
if github_app_id == '':
15+
raise Exception(standard_error_msg + 'Valid GITHUB_APP_ID is required to obtain an access token.')
16+
if github_installation_id == '':
17+
raise Exception(standard_error_msg + 'Valid GITHUB_INSTALLATION_ID is required to obtain an access token.')
18+
if private_key == '':
19+
raise Exception(standard_error_msg + 'Valid GITHUB_APP_PEM token is required to obtain an access token.')
20+
1321

1422
time_since_epoch_in_seconds = int(time.time())
1523

get-access-token.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ pip3 install cryptography
1111
pip3 install requests
1212
pip3 install PyJWT
1313

14-
export GITHUB_APP_ID=$SELENIARM_GITHUB_APP_ID
15-
export GITHUB_INSTALLATION_ID=$SELENIARM_GITHUB_INSTALLATION_ID
14+
export GITHUB_APP_ID="$SELENIARM_GITHUB_APP_ID"
15+
export GITHUB_INSTALLATION_ID="$SELENIARM_GITHUB_INSTALLATION_ID"
1616
export GITHUB_APP_PEM="$SELENIARM_GITHUB_APP_PEM"
1717

1818
python3 get-access-token.py

0 commit comments

Comments
 (0)