Skip to content

Commit 880cdaa

Browse files
authored
Merge pull request #6 from NarrativeScience/fix-github-basicauth
BUG FIX: GitHub deprecated basic authentication in their API
2 parents 1adad89 + 2548cad commit 880cdaa

File tree

5 files changed

+20
-4
lines changed

5 files changed

+20
-4
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
.DS_Store
22
orb.yml
3+
4+
.idea

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ repository and set the following environment variables:
3737
* `GITHUB_USERNAME` - Username of the service user that has read/write permissions to the repo.
3838
* `GITHUB_PASSWORD` - Password of the service user.
3939
* `GITHUB_EMAIL` - Email of the service user.
40+
* `GITHUB_TOKEN` - API token for the GitHub user
4041

4142
### Enabling Slack Notifications
4243

release.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
# Publishes and releases the version of the Orb to the CCI repo. Reads in Semantic version for the arg.
3+
# You must have a valid CCI token setup to run this script.
4+
5+
if [ $# -eq 0 ]
6+
then
7+
echo "The semantic version must be provided as an argument. I.E. '1.0.0'"
8+
else
9+
circleci config pack src > orb.yml
10+
circleci orb validate orb.yml
11+
circleci orb publish orb.yml "narrativescience/ghpr@$1"
12+
fi
13+

src/commands/get-pr-info.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ steps:
4141
4242
API_GITHUB="https://api.github.com/repos/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME"
4343
PR_REQUEST_URL="$API_GITHUB/pulls/$PR_NUMBER"
44-
PR_RESPONSE=$(curl --user "${GITHUB_USERNAME}:${GITHUB_PASSWORD}" "$PR_REQUEST_URL")
44+
PR_RESPONSE=$(curl -H "Authorization: token $GITHUB_TOKEN" "$PR_REQUEST_URL")
4545
4646
PR_TITLE=$(echo $PR_RESPONSE | jq -e '.title' | tr -d '"')
4747
echo "PR_TITLE: $PR_TITLE"
@@ -63,7 +63,7 @@ steps:
6363
6464
PR_MERGE_COMMIT_SHA=$(echo $PR_RESPONSE | jq -e '.merge_commit_sha' | tr -d '"')
6565
COMMIT_REQUEST_URL="$API_GITHUB/commits/$PR_MERGE_COMMIT_SHA"
66-
COMMIT_RESPONSE=$(curl --user "${GITHUB_USERNAME}:${GITHUB_PASSWORD}" "$COMMIT_REQUEST_URL")
66+
COMMIT_RESPONSE=$(curl -H "Authorization: token $GITHUB_TOKEN" "$COMMIT_REQUEST_URL")
6767
fi
6868
6969
<<# parameters.get_pr_author_email >>
@@ -80,7 +80,7 @@ steps:
8080
8181
<<# parameters.get_commit_message >>
8282
COMMIT_REQUEST_URL="$API_GITHUB/commits/$CIRCLE_SHA1"
83-
COMMIT_RESPONSE=$(curl --user "${GITHUB_USERNAME}:${GITHUB_PASSWORD}" "$COMMIT_REQUEST_URL")
83+
COMMIT_RESPONSE=$(curl -H "Authorization: token $GITHUB_TOKEN" "$COMMIT_REQUEST_URL")
8484
PR_COMMIT_MESSAGE=$(echo $COMMIT_RESPONSE | jq -e '.commit.message' | tr -d '"')
8585
echo "PR_COMMIT_MESSAGE: $PR_COMMIT_MESSAGE"
8686
echo "export GITHUB_PR_COMMIT_MESSAGE='$PR_COMMIT_MESSAGE'" >> $BASH_ENV

src/commands/post-pr-comment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ steps:
2222
curl \
2323
-X POST \
2424
-d "{\"body\": \"<< parameters.comment >>\"}" \
25-
--user "${GITHUB_USERNAME}:${GITHUB_PASSWORD}" \
25+
-H "Authorization: token $GITHUB_TOKEN" \
2626
"https://api.github.com/repos/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}/issues/${GITHUB_PR_NUMBER}/comments"

0 commit comments

Comments
 (0)