Skip to content

Commit

Permalink
Merge pull request #6 from NarrativeScience/fix-github-basicauth
Browse files Browse the repository at this point in the history
BUG FIX: GitHub deprecated basic authentication in their API
  • Loading branch information
ns-bdesimone authored Sep 30, 2020
2 parents 1adad89 + 2548cad commit 880cdaa
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
.DS_Store
orb.yml

.idea
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ repository and set the following environment variables:
* `GITHUB_USERNAME` - Username of the service user that has read/write permissions to the repo.
* `GITHUB_PASSWORD` - Password of the service user.
* `GITHUB_EMAIL` - Email of the service user.
* `GITHUB_TOKEN` - API token for the GitHub user

### Enabling Slack Notifications

Expand Down
13 changes: 13 additions & 0 deletions release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
# Publishes and releases the version of the Orb to the CCI repo. Reads in Semantic version for the arg.
# You must have a valid CCI token setup to run this script.

if [ $# -eq 0 ]
then
echo "The semantic version must be provided as an argument. I.E. '1.0.0'"
else
circleci config pack src > orb.yml
circleci orb validate orb.yml
circleci orb publish orb.yml "narrativescience/ghpr@$1"
fi

6 changes: 3 additions & 3 deletions src/commands/get-pr-info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ steps:
API_GITHUB="https://api.github.com/repos/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME"
PR_REQUEST_URL="$API_GITHUB/pulls/$PR_NUMBER"
PR_RESPONSE=$(curl --user "${GITHUB_USERNAME}:${GITHUB_PASSWORD}" "$PR_REQUEST_URL")
PR_RESPONSE=$(curl -H "Authorization: token $GITHUB_TOKEN" "$PR_REQUEST_URL")
PR_TITLE=$(echo $PR_RESPONSE | jq -e '.title' | tr -d '"')
echo "PR_TITLE: $PR_TITLE"
Expand All @@ -63,7 +63,7 @@ steps:
PR_MERGE_COMMIT_SHA=$(echo $PR_RESPONSE | jq -e '.merge_commit_sha' | tr -d '"')
COMMIT_REQUEST_URL="$API_GITHUB/commits/$PR_MERGE_COMMIT_SHA"
COMMIT_RESPONSE=$(curl --user "${GITHUB_USERNAME}:${GITHUB_PASSWORD}" "$COMMIT_REQUEST_URL")
COMMIT_RESPONSE=$(curl -H "Authorization: token $GITHUB_TOKEN" "$COMMIT_REQUEST_URL")
fi
<<# parameters.get_pr_author_email >>
Expand All @@ -80,7 +80,7 @@ steps:
<<# parameters.get_commit_message >>
COMMIT_REQUEST_URL="$API_GITHUB/commits/$CIRCLE_SHA1"
COMMIT_RESPONSE=$(curl --user "${GITHUB_USERNAME}:${GITHUB_PASSWORD}" "$COMMIT_REQUEST_URL")
COMMIT_RESPONSE=$(curl -H "Authorization: token $GITHUB_TOKEN" "$COMMIT_REQUEST_URL")
PR_COMMIT_MESSAGE=$(echo $COMMIT_RESPONSE | jq -e '.commit.message' | tr -d '"')
echo "PR_COMMIT_MESSAGE: $PR_COMMIT_MESSAGE"
echo "export GITHUB_PR_COMMIT_MESSAGE='$PR_COMMIT_MESSAGE'" >> $BASH_ENV
Expand Down
2 changes: 1 addition & 1 deletion src/commands/post-pr-comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ steps:
curl \
-X POST \
-d "{\"body\": \"<< parameters.comment >>\"}" \
--user "${GITHUB_USERNAME}:${GITHUB_PASSWORD}" \
-H "Authorization: token $GITHUB_TOKEN" \
"https://api.github.com/repos/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}/issues/${GITHUB_PR_NUMBER}/comments"

0 comments on commit 880cdaa

Please sign in to comment.